Collections and Collections Framework in Java | Java Collections | Java Tutorial For Beginners

preview_player
Показать описание
Please use the following link to install the Katalon Studio:

A Variable is a named reference to a memory area where value of the variable is stored.

Arrays:

Arrays are objects which store multiple variables of same type that are referred by a common name.

Limitations of Arrays:
Arrays are fixed in size, so we can not increase or decrease the size of the array according to our requirements.
To use arrays, we should know the size of the array in advance.
Arrays can hold only Homogeneous data type of elements.
Arrays are not implemented based on any standard Data Structures. So, no ready made methods available. Need to write our own logic to fulfill our requirements. It increases the complexity of the programming.

To overcome these problems, java introduced Collections concept.

Collection:
#javacollections #collectionsframework #collectioninterface

Collection is to represent a group of individual objects as a single entity.

Collections Framework:

The Java collections framework provides a set of interfaces and classes to implement various data structures and algorithms.

Advantages of Collections:
Collections are Growable in Nature. So, we can increase or decrease the size based on our requirement .
Collections can hold both Homogeneous and Heterogeneous elements.
Every collection is implemented based on some Standard Data Structure. So, we have ready made available methods for each requirement. We just need to use the suitable method according to our requirement.

Utility Classes in Collections:
The utility classes consists exclusively of static methods that operate on or return collections.
Collections
Arrays

Cursors in Collections:
If we want to get objects/elements one by one from the collection then we should use cursors.
Enumerator (interface)
Iterator (interface)
ListIterator (interface)

Sorting in Collections:
Java provides two interfaces to sort objects using data members of the class:

Comparable (interface)
Comparator (interface)

Рекомендации по теме