NavigableSet lower() method in Java Last Updated : 29 Sep, 2018 Comments Improve Suggest changes Like Article Like Report The lower() method of NavigableSet interface in Java is used to return the greatest element in this set strictly less than the given element, or null if there is no such element exists in the set. Syntax: E lower(E ele) Where, E is the type of elements maintained by this Set container. Parameters: This function accepts a parameter ele which refers to type of element maintained by this Set container. Return Value: It returns the greatest element in this set strictly less than the given element, or null if there is no such element. Below programs illustrate the lower() method in Java: Program 1: NavigableSet with integer elements. Java // A Java program to demonstrate lower() // method of NavigableSet import java.util.NavigableSet; import java.util.TreeSet; public class GFG { public static void main(String[] args) { NavigableSet<Integer> ns = new TreeSet<>(); ns.add(0); ns.add(1); ns.add(2); ns.add(3); ns.add(4); ns.add(5); ns.add(6); System.out.println("Greatest element strictly less than" + " 4 is: " + ns.lower(4)); } } Output: Greatest element strictly less than 4 is: 3 Program 2: NavigableSet with string elements. Java // A Java program to lower() // method of NavigableSet import java.util.NavigableSet; import java.util.TreeSet; public class GFG { public static void main(String[] args) { NavigableSet<String> ns = new TreeSet<>(); ns.add("A"); ns.add("B"); ns.add("C"); ns.add("D"); ns.add("E"); ns.add("F"); ns.add("G"); System.out.println("Greatest element strictly less than" + " D is: " + ns.lower("D")); } } Output: Greatest element strictly less than D is: C Reference: https://docs.oracle.com/javase/10/docs/api/java/util/NavigableSet.html#lower(E) Comment More infoAdvertise with us Next Article NavigableSet pollFirst() method in Java B barykrg Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions Java-NavigableSet +2 More Practice Tags : JavaJava-CollectionsMisc Similar Reads NavigableSet in Java In Java, the NavigableSet is a subtype of the SortedSet interface. It allows us to perform various operations like getting the closest matches for a given element, descending order iteration, and others. It provides methods to navigate through the elements in the set.For Example, The NavigableSet in 9 min read NavigableSet ceiling() method in Java The ceiling() method of NavigableSet interface in Java is used to return the least element in this set greater than or equal to the given element, or null if there is no such element. Syntax: E ceiling(E ele) Where, E is the type of elements maintained by this Set container. Parameters: This functio 2 min read NavigableSet descendingIterator() method in Java The descendingIterator() method of NavigableSet interface in Java is used to return an iterator over the elements in this set, in descending order. This iterator can be then used to iterate over the elements of the set. The iterator returned by this set is also equivalent to descendingSet().iterator 2 min read NavigableSet descendingSet() method in Java The descendingSet() method of NavigableSet interface in Java is used to return a reverse order view of the elements contained in this set. The descending set is backed by this set, so any changes to the set are reflected in the descending set, and vice-versa. If any of the set is modified while an i 2 min read NavigableSet floor() method in Java The floor() method of NavigableSet interface in Java is used to return the greatest element in this set less than or equal to the given element, or null if there is no such element exists in the set. Syntax: E floor(E ele) Where, E is the type of elements maintained by this Set container. Parameters 2 min read NavigableSet headSet() method in Java The headSet() method of NavigableSet interface in Java is used to return a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa.The 2 min read NavigableSet higher() method in Java The higher() method of NavigableSet interface in Java is used to return the least element in this set strictly greater than the given element, or null if there is no such element exists. Syntax: E higher(E ele) Where, E is the type of elements maintained by this Set container. Parameters: This funct 2 min read NavigableSet iterator() method in Java The iterator() method of NavigableSet interface in Java is used to return an iterator over the elements in this set, in ascending order. This iterator can be then used to iterate over the elements of the set. Syntax: Iterator<E> iterator() Where, E is the type of elements maintained by this Se 2 min read NavigableSet lower() method in Java The lower() method of NavigableSet interface in Java is used to return the greatest element in this set strictly less than the given element, or null if there is no such element exists in the set. Syntax: E lower(E ele) Where, E is the type of elements maintained by this Set container. Parameters: T 2 min read NavigableSet pollFirst() method in Java 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 paramete 1 min read Like