Home > DeveloperSection > Forums > Differentiate between collection and collections
Sanjay Sharma
Sanjay Sharma

Total Post:45

Points:315
Posted on    July-28-2015 7:18 AM

 Java Java  Collection 
Ratings:


 1 Reply(s)
 375  View(s)
Rate this:
I am very confuse about what is the difference between Collection and Collections


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Posted on    July-28-2015 8:56 AM

Collection, as its javadoc says is "The root interface in the collection hierarchy." This means that every single class implementing Collection in any form is part of the Java Collections Framework.

The Collections Framework is Java's native implementation of data structure classes (with implementation specific properties) which represent a group of objects which are somehow related to each other and thus can be called a collection.

Collections is merely an utility method class for doing certain operations, for example adding thread safety to your ArrayList instance by doing this:

List<MyObj> list = Collections.synchronizedList(new Arraylist<MyObj>());
The main difference in my opinion is that Collection is base interface which you may use in your code as a type for object (although I wouldn't directly recommend that) while Collections just provides useful operations for handling the collections.

Don't want to miss updates? Please click the below button!

Follow MindStick