Update appNew update is available. Click here to update.

Introduction

Introduction to Collections

Implementation of Collections

Why Java Collections ?

Java Collection Framework Hierarchy

Collection Interface

Iterator Interface

Iterable Interface

List Interface

Queue Interface

Set Interface

0% completed

Package Containing All Classes

Not Part Of

Delete All Elements

Grows Dynamically

Size of an Object

Collection Algorithms

Example Problems

Basics Of Java
Report an issue
Introduction to Collections

 

Introduction to Collections

 

Introduction

 

Before diving into the "technical stuff," it's important for a beginner to understand what a "Collection" is. Quite intriguing, isn’t it? However, you might already know what it is, or you can look it up in the dictionary - it means “a group of things or people.

 

Now, let us try to relate the meaning of the word in the light of technical learning.

“Things or People” - Can you recall and relate it to any of the lectures from our Data Structures and Algorithms course? Okay, for those of you who have not taken the course with us, let me take this opportunity to explain.

“Things or People” have a lot of attributes/properties and functionalities. Are you confused? Don’t worry; let me get this through.

 

For instance, take a car, which you can say is a “thing” or an “object”; doesn’t that sound familiar to you? Anyway, let’s look closely. A car has quite a few attributes or properties, such as the color, model name, manufacturer’s name, whether the car runs on petrol or diesel, etc. A car has also gotten some functionalities. One of the significant functionalities is carrying passengers to point A to point B.

 

So, in Object-Oriented Programming(OOP), we see everything as an object! An object has attributes and functions. Moreover, they are closely bound or coupled, which is the idea of Encapsulation to represent a real-world entity. Similarly, a person can also be referred to as an object. Example, Employee! 

In OOP, we have data all around. We store and edit them as objects and do manipulation to carry out a specific task, say, sorting objects based on a property!

 

Let’s revisit the definition of “Collection” from the dictionary now. So, Collection is “a group of things or people”, but now we know things or people are Objects in the world of programming. Hence, can I not say that a Collection is a group of objects? I certainly can.

 

Now, let’s look at it in the light of Java. Collections are a group of objects that help us to carry out some specific tasks “efficiently”.

 

Let’s dive deeper into the implementation of this concept.