Java SortedSet Interface

SortedSet interface extends Set interface in collection framework of java. As name suggest, It provides total ordering on elements of Set. Set elements will be ordered using their natural ordering or using a comparator interface. All the elements entries of SortedSet must implement Comparable interface. All the elements of SortedSet must be comparable. So e1.compareTo(e2) … Read more

HashSet in Java Collection Example

HashSet is a class of collection framework which extends AbstractSet class and implements the Set interface. HasSet doesn’t guarantee that elements order will remain same over the time and returned in any random order. HasSet doesn’t allow duplicate values. If you try to insert duplicate, It will overwrite. HasSet allows to store null values. HasSet … Read more

Java LinkedHashSet Class

LinkedHashSet Class extends extends HashSet class and Implements Set interface in collection interface hierarchy. LinkedHashSet implementation differs from HashSet as it maintains doubly-linked list running through all of its entries. It maintains element’s entries in set as per it’s insertion order. So it will allow you insertion order iteration over the set. So when you iterate over LinkedHashSet, … Read more

Java Set Interface And Methods

Set is one of the collection framework interface which extends root Collections interface. Set collection can not contain duplicate elements. Set interface has all methods which are inherited from Collection interface with special restriction of not allowing duplicate elements. If two Set interface contains same elements then both are equal. Set interface is implemented by … Read more