Java Collections Tutorial Part - 2

collection
java
linked-list
queue
sets
tutorial

#1

In the previous tutorial, we have seen the introduction to JCF and Iterators. In this tutorial,
lets look into the details of Collection Interfaces and Classes.

THE COLLECTION INTERFACES

The Collection Classes implementing these interfaces have the functionality of these
interfaces. Therefore, these interfaces define the core behavior of a Collection class.

alt text

THE COLLECTION ABSTRACT CLASSES

The Abstract Classes provide skeletal implementations that are used as starting points for
creating concrete Collections.

alt text

THE COLLECTION CLASSES

These standard classes provide full implementation of the Collection that can be used
as-is.

The below table shows various differences between the Collection classes. The terms used
in the table are -

1) AD - Allow Duplicates: It tells whether that particular collection allows duplicate values
to be inserted.

2) AN - Allow Null: It tells whether null objects can be inserted into that particular
collection.

3) Inserted Order: It tells whether the objects are stored in the same order in which they
were inserted.

4) Sorted Order: It tells whether the objects are stored in sorted order.

5) Synchronized: It tells whether the collection is thread-safe or not.

6) Random Access: It tells whether the collection has a get() method to returns the index
of an object or return the object using an index.

7) Default capacity: The initial capacity of the collection when it is created using an empty
constructor.

alt text

The Time Complexities of basic operations are given below:

alt text

Click here to go to next tutorial


Java Collections Tutorial Series:

Java Collections Tutorial Part - 1

Java Collections Tutorial Part - 2

Java Collections Tutorial Part - 3

Java Collections Tutorial Part - 4


#2

Keep up the effort! There are few materials for java in competitive programming and from my experience, it is really a great language due to the Collections framework.This will definitely benefit school programmers who are just getting started as java is way more common , at least in Indian schools:)


#3

Good. That’s great. Carry on.