What is Collections Framework in Java?
The Java Collections Framework (JCF) is a set of classes and interfaces provided by Java to store, manage, and manipulate groups of objects efficiently.
Before Collections, developers mainly used arrays. Arrays have a fixed size and limited functionality. Collections provide dynamic storage and many built-in methods for handling data.
Package : java.util
Why is Collections Used?
Collections are used to:
Store multiple objects dynamically.
Perform searching, sorting, insertion, and deletion easily.
Reduce coding effort through built-in methods.
Improve code reusability and maintainability.
Handle large amounts of data efficiently.
Without Collections
int [] arr = new int [ 100 ];
Enter fullscreen mode
Exit fullscreen mode
Fixed size
Difficult to resize
Limited operations
With Collections
ArrayList < Integer > list = new ArrayList <>();
Enter fullscreen mode
Exit fullscreen mode
Dynamic size
Easy insertion and deletion
Rich utility…