HTML Java

Java Collections


Collection Framework Introduces in Java JDK(1.2)

Its use to achieve the data structure functionality, Data Structure is a concept in which we want to store data in organized manner. So in Data structure we want to keep huge data at common place together in structured manner so that it consume less memory and store more data and that data where we store if we want to fetch that data so its fetch in efficient manner and its address should be managed.


Data Structure is of two types

  • Linear Data Structure: Array, Array List, Linked List, Stack, Vector
  • Non Linear Data Structure: Tree, Graph, Map

We can store data in either Program or in Secondary Memory like Database.

So if we want to store data in Program in structure manner than Data Structure Helps.



Array

  • Array is a collection of similar (homogeneous) types of data in the contiguous memory location.
  • Collection Framework facilitates us to store similar (homogeneous) and dissimilar (heterogeneous) types of data.
  • In collection framework resizable data storage facility was given.
  • In array if we give a size once then its fixed we can’t store more elements into it. And it’s not resizable.

But when we store data in collection framework size is resizable. Because ArrayList, LinkedList, etc is resizable. Or we can say it provides resizable array to store data.



Collection is an interface and Collections is a class

  • Implementing classes of List interfaces: ArrayList, Vector, LinkedList, Stack.
  • They all are concrete classes. Concrete classes are those classes which internally implementing any interface and extending any abstract class.
  • They all are providing the concrete implementation of List interface.

Iterator, ListIterator, Enumeration, Comparator, Comparable all are interfaces.

List interface is a child interface of collection it providing the facility to store the elements in indexing manner here we can jump the position it also allowed the duplicate element in insertion order.