VOOZH about

URL: https://www.geeksforgeeks.org/java/navigableset-pollfirst-method-in-java/

⇱ NavigableSet pollFirst() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

NavigableSet pollFirst() method in Java

Last Updated : 11 Jul, 2025
The pollFirst() method of NavigableSet interface in Java is used to retrieves and removes the first (lowest) element, or returns null if this set is empty. Syntax:
E pollFirst()
Where, E is the type of elements maintained by this Set container. Parameters: This function does not accepts any parameter. Return Value: It returns returns null if this set is empty. Below programs illustrate the pollFirst() method in Java: Program 1: NavigableSet with integer elements.
Output:
First lowest element removed is : 0
Program 2: NavigableSet with string elements.
Output:
First lowest element removed is : A
Reference: https://docs.oracle.com/javase/10/docs/api/java/util/NavigableSet.html#pollFirst(E)
Comment