A collection is simply an object that represents a group of objects into a single unit.
Collection framework:
A collection framework is a unified architecture or a set of classes and interfaces for representing and manipulating collections. i.e. collection framework is used to store, retrieve and manipulate collections.
Collection framework contains the following:
- Interfaces are abstract data types that represent collections and allow collections to be manipulated independently of the details of their representation.
- Classes/Implementations are the concrete implementations of the collection interfaces.
- Algorithms: are the methods used for collection computations, like searching and sorting.
Advantages/Benefits of collection framework:
- Reduces programming effort: Collection framework provides useful data structure and algorithms for collection manipulation, you not have to write them.
- Increases program speed and quality: The collection framework provides high-performance and high-quality implementations of useful data structures and algorithms which increase the speed and quality.
- Resizable: Collection is resizable.
- Reduces effort to design new APIs: because the collection framework eliminates the need to produce ad hoc collections APIs.
Disadvantages of collection framework:
- It must cast to the correct type.
- It can’t be done compile-time type checking.
Note: Above two disadvantages can be removed from the collection framework by using generics.
Core Collection Framework interfaces are categories into two sets collections and maps.
Note: Maps are not an integral part of the collection framework but are considered as collections because they can store and manipulate groups of objects like collections.
Collection tutorial:
- Collection interfaces.
- Set interface
- SortedSet interface
- List interface
- Map interface
- Map.Entry interface
- SortedMap interface
- Queue interface
- Deque interface
- Enumeration interface
- Collection classes
- HashSet
- LinkedHashSet
- TreeSet
- ArrayList
- LinkedList
- HashMap
- LinkedHashMap
- TreeMap
- PriorityQueue
- ArrayDeque
- Abstract classes in collection framework
- Sorting
- Comparable interface
- Comparator interface
- Properties class
- Hashtable
- ListIterator interface
- Java Vector class
- ArrayList vs LinkedList vs Vector
- Iterator vs ListIterator vs Enumeration
- List vs Set Vs Map
- HashSet vs LinkedHashSet vs TreeSet
- HashMap vs LinkedHashMap vs TreeMap vs HashTable
- HashSet vs HashMap vs HashTable
- Collection vs collections
- Comparable vs Comparator interfaces
- Java hashcode and equals methods
- HashMep internal working
- HashMap null key
- HashSet internal working
- Collection framework interview programs