Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the main difference between Collection and Collections in Java? [closed]

What is the main difference between Collection and Collections in Java?

like image 699
Nirmal Avatar asked Nov 25 '09 11:11

Nirmal


People also ask

What is difference between collection and collections in Java?

In Java, collection is an interface. In Java, collections is a utility class. 2. It showcases a set of individual objects as a single unit.

What are the main differences between collection and collections?

Collection is the interface where you group objects into a single unit. Collections is a utility class that has some set of operations you perform on Collection. Collection does not have all static methods in it, but Collections consist of methods that are all static.

What is the difference between Java collection and Java collections Javatpoint?

The differences between the Collection and Collections are given below. The Collection is an interface whereas Collections is a class. The Collection interface provides the standard functionality of data structure to List, Set, and Queue. However, Collections class is to sort and synchronize the collection elements.

What are different collections in Java?

Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet).


2 Answers

Collection is a base interface for most collection classes, whereas Collections is a utility class. I recommend you read the documentation.

like image 55
Mirek Pluta Avatar answered Oct 14 '22 21:10

Mirek Pluta


Are you asking about the Collections class versus the classes which implement the Collection interface?

If so, the Collections class is a utility class having static methods for doing operations on objects of classes which implement the Collection interface. For example, Collections has methods for finding the max element in a Collection.

The Collection interface defines methods common to structures which hold other objects. List and Set are subinterfaces of Collection, and ArrayList and HashSet are examples of concrete collections.

like image 41
uckelman Avatar answered Oct 14 '22 22:10

uckelman