Syntax error NavigableSet Class lower() method in Java

NavigableSet Class lower() method in Java



The lower() method of NavigableSet returns the greatest element strictly less than the given element i.e. 35 here −

lower(35);

The following is an example to implement the lower() method in Java −

Example

 Live Demo

import java.util.NavigableSet;
import java.util.TreeSet;
public class Demo {
   public static void main(String[] args) {
      NavigableSet<Integer> set = new TreeSet<>();
      set.add(10);
      set.add(25);
      set.add(40);
      set.add(55);
      set.add(70);
      set.add(85);
      set.add(100);
      System.out.println("Returned Value = " + set.lower(35));
   }
}

Output

Returned Value = 25
Updated on: 2019-07-30T22:30:24+05:30

97 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements