The first() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the first (lowest) element currently in this set.
Return Value: The function returns the first (lowest) element currently in this set.
Exception: The function throws NoSuchElementException if this set is empty.
Below programs illustrate the ConcurrentSkipListSet.first() method:
The lowest element in the set: 10
Program 2: Program to show NoSuchElementException in first().
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.