In this tutorial we will learn what is java.util.Collection 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 this interface, but it provides classes which are implementations of more specific subinterfaces like Set and List in java.
java.util.Set extends java.util.Collection interface in java.
HashSet, CopyOnWriteArraySet, LinkedHashSet, TreeSet, ConcurrentSkipListSet, EnumSet classes implements Set interface.
java.util.List extends java.util.Collection interface in java.
Generally speaking a collection represents a group of objects, known as its elements.
Let's discuss feature/properties of java.util.Collection in java >
- Some allow Duplicate elements.
- Some maintains insertion order.
- Some are Sorted by natural order.
- Some are synchronized.
- Some allow null elements.
Advantages of using java.util.Collection in java >
- Performance - JDK provides many classes which implements subInterface of Collection like java.util.List and java.util.Set interface.
- Optimised and tested - Collection implementations are optimised and well tested in java.
- Reusability - They can be reused in java.
It’s important to note java.util.Map interface is a member of the Java Collections Framework, but it does not implement java.util.Collection interface in java.
So in this tutorial we learned what is java.util.Collection in java.
/** JavaMadeSoEasy.com */
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.
Must read for you :