Differences between Collection and Collections in java


In this Collection framework tutorial we will learn what are differences between java.util.Collection and java.util.Collections in java.


java.util.Collection is the root interface in the ​hierarchy of Java Collection framework​.
The JDK does not provide any classes which directly implements java.util.Collection interface, but it  provides classes such as ArrayList, LinkedList, vector, HashSet, EnumSet, LinkedHashSet, TreeSet, CopyOnWriteArrayList, CopyOnWriteArraySet, ConcurrentSkipListSet  which implements more specific subinterfaces like ​Set and List​ in java.


java.util.Collections is a utility class which consists of static methods that operate on or return Collection in java.

java.util.Collections provides method like >
  • reverse method for reversing List in java.
  • shuffle method for shuffling elements of List in java.
  • unmodifiableCollection, unmodifiableSet, unmodifiableList, unmodifiableMap methods for making List, Set and Map unmodifiable in java.
  • min method to return smallest element in Collection in java.
  • max method to return smallest element in Collection.
  • sort method for sorting List.
  • synchronizedCollection,  synchronizedSet, synchronizedList, synchronizedMap methods for synchronizing List, Set and Map respectively in java.


Additionally you must know that java.util.Collection and java.util.Collections both were introduced in second version of java i.e. in JDK 2.0.

So in this Collection framework tutorial we learned what are differences between java.util.Collection and java.util.Collections in java.



Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.


/** JavaMadeSoEasy.com */

RELATED LINKS>

Collection tutorial in java - java.util.List, java.util.Set and java.util.Map all properties in tabular form


Iterator vs ListIterator - Similarity and Differences in java


Comparable vs Comparator - differences and sorting list by implementing Comparable and Comparator in classes and inner classes in java



List hierarchy tutorial in java - Detailed - java.util.ArrayList, java.util.LinkedList, java.util.vector, java.util.concurrent.CopyOnWriteArrayList classes


Set hierarchy tutorial in java - Detailed - java.util.HashSet, java.util.concurrent.CopyOnWriteArraySet, java.util.LinkedHashSet, java.util.TreeSet, java.util.concurrent.ConcurrentSkipListSet, java.util.EnumSet classes


Map hierarchy tutorial in java - Detailed - java.util.HashMap, java.util.Hashtable, java.util.concurrent.ConcurrentHashMap, java.util.LinkedHashMap, java.util.TreeMap, java.util.concurrent.ConcurrentSkipListMap, java.util.IdentityHashMap, java.util.WeakHashMap, java.util.EnumMap classes



Basic Collection - All properties in tabular form >

Collection - List, Set and Map all properties in tabular form



No comments:

Post a Comment