What is the difference between "collection" ,"Collection" and "Collections"? [duplicate]

The Java collections framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures.

Collection is an interface .

The root interface in the collection hierarchy. A collection represents a group of objects, known as its elements. Some collections allow duplicate elements and others do not. Some are ordered and others unordered. The JDK does not provide any direct implementations of this interface: it provides implementations of more specific subinterfaces like Set and List. This interface is typically used to pass collections around and manipulate them where maximum generality is desired.

Collections is a utility class , which has specific methods to work with collections.

This class consists exclusively of static methods that operate on or return collections. It contains polymorphic algorithms that operate on collections, “wrappers”, which return a new collection backed by a specified collection, and a few other odds and ends.

Read Oracle Java Collections tutorial

“collection” is a term to denote a container for elements. It is not a keyword or any class/interface name in Java. It can be used as an identifier to refer to a Collection. Probably you must have seen this :

Collection<String> collection ;

A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data. Typically, they represent data items that form a natural group.

Browse More Popular Posts

Leave a Comment