The last() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the last (highest) element currently in this set.
public E last()
Return Value: The function returns returns the last (highest) element currently in this set.
Exception: The function throws the NoSuchElementException if this set is empty.
Below programs illustrate the ConcurrentSkipListSet.last() method:
The highest element of the set: 78
Program 2: Program to show NoSuchElementException in last().
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.