Java Collection

12 / 100

What is a collection in java

A collection is an object that groups one or more than one element into a single unit. Collection framework provides interfaces and classes to store, retrieve and manipulate the data.

A collection framework contains interfaces, implementations and classes

  • interfaces -Interfaces allow collections to be manipulated independently of the details of their representation
  • implementations– These are reusable data structures.

Benefit of using collection:-

  • We can add any objects to the collection.
  • We can remove any objects from the collection.
  • We can identify an object or group of objects from the collection.
  • We can iterate/loop through the entire collection using utility classes.

Followings are the some list of Collection classes in Java:

For sorting of collection use following interfaces:

Apart from above topic there are some interesting fact about Java Collection:

  • How HashMap works internally in Java (Most frequent ask interview question in Java).
  • How HashSet works internally in Java.
  • Custom key in Hashmap.
  • How to create custom Hashset in Java
  • What is fail fast and fail safe example in java
  • Unmodifiable List in Java or read-only list in Java.

We are still working on more Java collection interview questions.

%d bloggers like this: