Learnitweb

What is the difference between Collection and Collections ?

  • Collection is an interface whereas Collections is a class.
    public interface Collection<E> extends Iterable<E>
    public class Collections extends Object
  • Collection is an interface in Java. Most of the classes in Java Collection Framework inherit from this interface. List, Set and Queue are main sub interfaces of this interface. JDK doesn’t provide direct implementations of this interface. But, JDK provides direct implementations of it’s sub interfaces. ArrayList, HashSet and PriorityQueue are some indirect implementations of Collection interface.
    Whereas Collections is a class. Collections class extends Object class. Both Collection interface and Collections class are in java.util package.
  • The Collection interface provides methods which provide the standard functionality of data structure to it’s sub interfaces and implementation classes.
    Collections class is a utility class which provides static methods to operate on collections. For example, Collections class provides methods to sort, find maximum element in a collection.