What is ?

Collections Framework was introduced in Java 1.2 . The Java collections framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures. Collection framework has many different interfaces and classes. Each and every interface and class has different purpose. We can perform add, edit, delete etc., operations on group of objects as per methods and implementation of a class.

What is a Collection?

A collection is an object that represents a group of individual objects represented as a single unit. Collection is a dynamic array where we can add elements and reduce elements.

Arrays vs Collections:

Both Collections and Arrays hold references to Objects and can be managed as a group.

Collections do not need to be assigned a certain capacity when instantiated where as Arrays need to be assigned certain capacity when instantiated.

Collections can grow and shrink in size automatically when objects are added or removed where as Arrays contain fixed size.

Collections cannot hold basic data type elements (primitive types such as int, long, or double; instead, they hold Wrapper Classes such as Integer, Long, or Double) where as Arrays hold basic data type elements.

Collections Framework In Java

Types of Collections:

There are also three generic types of collection: Ordered lists, Maps, and Sets.

Collections Framework contains following interfaces

1. Set
2. List
3. Queue
4. Deque

Some of the classes are as follows

1. ArrayList
2. Vector
3. LinkedList
4. HashSet
5. TreeSet
6. PriotyQueue

Source link https://www.softwaretestingmaterial.com/collections-framework-in-java/


Please enter your comment!
Please enter your name here