Course Content

Course Content

Description

Collections in Java

In the previous video of our ongoing course of Core Java we have seen that what is Multithreading in Java programming language. In this video we are going to learn about what are Collections in Java language.

Collections in Java programming language is a framework that provides an architecture to store and manipulate the group of objects. All the operations in Java that you can perform on a data such as searching, sorting, insertion, manipulation, deletion, etc... can be performed by Collections in Java.

Collection in Java simply means a single unit of Objects. While Framework in Java provides readymade architecture and represents set of classes and interface.

Collection framework represents a unified architecture for storing and manipulating group of objects in Java programming.

‘java.util’ package contains all the classes and interfaces for Collection framework.

Some of the important interfaces of Collection API are as follows :
1. Collection : enables you to work with groups of object, it is at the top of collection hierarchy.
2. Deque : extends queue to handle double ended queue.
3. List : extent collection to handle sequences list of object.
4. Queue : extends collection to handle special kind of list in which element are removed only from the head.
5. Set : extent collection to handle sets.

The Java Collection framework package contains a set of interfaces, implementation classes, and algorithms (such as sorting in java and searching in java).

The Array list in Java is a linear data structure similar to the array, but resizable. The list interface extends Collection and declares the behaviour of a collection that stores a sequence of elements.

Elements can be inserted or accessed by their position in the list, using a zero based index. A list may contain duplicate elements.

Example :
import java.util.*;
public class Collection
{
public static void main(String[] args)
{
List a1 = new ArrayList ();
a1.add("tops");
a1.add("venture");
a1.add("ibm");
System.out.println("ArrayList elements"); System.out.print ("\t" + a1);
List li = new LinkedList ();
li.add("hir");
li.add("hiral");
li.add("shastri"); System.out.println();
}
} }

So, this is what Collections in Java are, and we have also seen some important interfaces of Collection API in Java. Now, in the next video our topic is List Interface in Java and Map Interface in Java with understandable example.

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere