the java collection framework is a set of interface and classes. that provides ready-made architecture used to store and manage multiple objects dynamically.
why use collections
array have some limitations:
- fixed size
- difficult insertion and deletion
- Limited built-in operations
collections solve those problems by providing dynamic data structure and useful methods.
main interfaces in collections framework
1. Collection interface
Collection interface is super(parent) interface.
List
list is a sub interface(child) of collection interface.
list extends collection.
List interface supports
- maintain insertion order
- Allow duplicate elements
- Supports index-based access
Example
- ArrayList
- LinkedList
Set
set also sub interface(child) of a collection interface.
set extends collection
Set interface supports
- set dose not allow duplicate
- no index based-access
Example
- HashSet
- LinkedHashSet
- TreeSet
Map
map is a interface, That stores data in key value pairs.
map implemented classes
- HashMap
- LinkedHashMap
- TreeMap
- Hashtable
*Advantage of Collections *
- Dynamic size
- Easy insertion and deletion
- built-in sorting and searching
- better code reusability
Top comments (0)