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.
Syntax:
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:
Program 1:
Output:
The highest element of the set: 78
Program 2: Program to show NoSuchElementException in last().