Collections Framework in Java

What is Java Collections Framework?

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

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

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap