All About the SortedSet Interface in Collection In java


The SortedSet interface is used to sort elements of a collection in ascending order.The SortedSet interface extends Set interface which in turn extends Collection Interface.The SortedSet interface does not allow duplicate elements in a Set.

The below methods are extra apart from Set Interface:

comparator();// Returns the comparator object.If the elements in the SortedSort are in ascending order
//then it returns null.
first();//Returns the first element of the SortedSet.
headSet(Object toElement);//Returns the number of elements less than that of the elements specified
//using toElement object.The elements are returned from the SortedSet.
last();//returns the last element from the SortedSet.
subSet(Object fromElement,Object toElement);//returns the elements between the range specified.
tailSet(Object fromElement);//returns the elements from a SortedSet that are greater than or equal 
//to fromElement.
 
All About the SortedSet Interface in Collection In java All About the SortedSet Interface in Collection In java Reviewed by Animesh Chatterjee on December 19, 2018 Rating: 5

No comments:

Powered by Blogger.