Collection is kind of a container which is simply an object or groups of multiple object into a single package. Collections are used to store, manipulate and retrieve data. The real world example, such as a pack of cards , telephone directory and vegetable basket with vegetables. Collection was introduced in-JDK 1.2 versions of the Java platform. Before JDK 1.2, Some standard methods for grouping Java objects via array, Vector Hashtable classes.
Collections framework is unified architecture for representing and manipulating collections. It is contains a set of classes and interfaces that achieve to implementation of data structures.
Collections frameworks contain the following:
Advantages
Core collection interfaces are the foundation of the Java Collections Framework. you can see below figure, the core collection interfaces form a hierarchy.
The following list describes the core collection interfaces:
The java.util package contains all the classes and interfaces for the Collection framework.
Interface Iterable<T> : This interface is an object to be target of the "for-each loop" statement.
Abstract method.
Iterator<T> iterator(); //It returns the iterator elements T type
Default method
1) forEach(Consumer<? super T> action)
2) spliterator()
Interface Iterator<E> : Iterator interface represents an object capable of iterating through a collection of objects, one object at a time. Iterator takes the place of Enumeration in the Java Collections Framework. Iterator is differ from enumeration in two ways:
Abstract method.
1) hasNext() //Returns true if the iteration has more elements.
2) next() //Returns the next element in the iteration.
Interface Collection<E> :