Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Collection vs Collections in Java with Example

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Collection: Collection is a interface present in java.util.package. It is used to represent a group of individual objects as a single unit. It is similar to the container in the C++ language. The collection is considered as the root interface of the collection framework. It provides several classes and interfaces to represent a group of individual objects as a single unit. 

The List, Set, and Queue are the main sub-interfaces of the collection interface. The map interface is also part of the java collection framework, but it doesn’t inherit the collection of the interface. The add(), remove(), clear(), size(), and contains() are the important methods of the Collection interface.


public interface Collection<E> extends Iterable<E>

Type Parameters: E - the type of elements returned by this iterator

Collections: Collections is a utility class present in java.util.package. It defines several utility methods like sorting and searching which is used to operate on collection. It has all static methods. These methods provide much-needed convenience to developers, allowing them to effectively work with Collection Framework. For example, It has a method sort() to sort the collection elements according to default sorting order, and it has a method min(), and max() to find the minimum and maximum value respectively in the collection elements.


public class Collections extends Object

Collection vs Collections:                                                           

                                  Collection                                          Collections
It is an interface.It is a utility class.
It is used to represent a group of individual objects as a single unit. It defines several utility methods that are used to operate on collection.
The Collection is an interface that contains a static method since java8. The Interface can also contain abstract and default methods.It contains only static methods.


// Java program to demonstrate the difference  
// between Collection and Collections
import java.util.*;
class GFG {
    public static void main (String[] args) 
      // Creating an object of List<String>
      List<String> arrlist = new ArrayList<String>(); 
      // Adding elements to arrlist
      // Printing the elements of arrlist
      // before operations
      System.out.println("Elements of arrlist before the operations:");
      System.out.println("Elements of arrlist after the operations:");
      // Adding all the specified elements
      // to the specified collection
      Collections.addAll(arrlist, "web", "site");
      // Printing the arrlist after
      // performing addAll() method
      // Sorting all the elements of the  
      // specified collection according to 
      // default sorting order
      // Printing the arrlist after
      // performing sort() method


Elements of arrlist before the operations:
[geeks, for, geeks]
Elements of arrlist after the operations:
[geeks, for, geeks, web, site]
[for, geeks, geeks, site, web]

My Personal Notes arrow_drop_up
Last Updated : 02 Sep, 2020
Like Article
Save Article
Similar Reads
Related Tutorials