Question: What are the Methods of Java TreeSet Class?

Answer: Method:  boolean add(E e)
Description:  It is used to add the specified element to this set if it is not already present.

Method:  boolean addAll(Collection<? extends E> c)
Description:  It is used to add all of the elements in the specified collection to this set.

Method:  E ceiling(E e)
Description:  It returns the equal or closest greatest element of the specified element from the set, or null there is no such element.

Method:  Comparator<? super E> comparator()
Description:  It returns a comparator that arranges elements in order.

Method:  Iterator descendingIterator()
Description:  It is used to iterate the elements in descending order.

Method: NavigableSet descendingSet()
Description:  It returns the elements in reverse order.

Method:  E floor(E e)
Description:  It returns the equal or closest least element of the specified element from the set, or null there is no such element.

Method:  SortedSet headSet(E toElement)
Description:  It returns the group of elements that are less than the specified element.

Method:  NavigableSet headSet(E toElement, boolean inclusive)
Description:  It returns the group of elements that are less than or equal to(if, inclusive is true) the specified element.

Method:  E higher(E e)
Description:  It returns the closest greatest element of the specified element from the set, or null there is no such element.

Method:   Iterator iterator()
Description:  It is used to iterate the elements in ascending order.

Method:   E lower(E e)
Description:  It returns the closest least element of the specified element from the set, or null there is no such element.

Method:  E pollFirst()
Description:  It is used to retrieve and remove the lowest(first) element.

Method:  E pollLast()
Description:  It is used to retrieve and remove the highest(last) element.

Method:  Spliterator spliterator()
Description:  It is used to create a late-binding and fail-fast spliterator over the elements.

Method:  NavigableSet subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
Description: It returns a set of elements that lie between the given range.

Method:  SortedSet subSet(E fromElement, E toElement))
Description: It returns a set of elements that lie between the given range which includes fromElement and excludes toElement.

Method:  SortedSet tailSet(E fromElement)
Description: It returns a set of elements that are greater than or equal to the specified element.

Method:   NavigableSet tailSet(E fromElement, boolean inclusive)
Description:  It returns a set of elements that are greater than or equal to (if, inclusive is true) the specified element.

Method:   boolean contains(Object o)
Description: It returns true if this set contains the specified element.

Method:   boolean isEmpty()
Description: It returns true if this set contains no elements.

Method:   boolean remove(Object o)
Description: It is used to remove the specified element from this set if it is present.

Method:   void clear()
Description: It is used to remove all of the elements from this set.

Method:   Object clone()
Description: It returns a shallow copy of this TreeSet instance.

Method:   E first()
Description: It returns the first (lowest) element currently in this sorted set.

Method:   E last()
Description: It returns the last (highest) element currently in this sorted set.

Method:  int size() 
Description: It returns the number of elements in this set.