Example of higher(Element) method of navigableSet in java.
Example of higher(Element) method of navigableSet in java.
Here, you will see the use of higher(Element) method in java. It returns a element. That is least element in this set strictly greater than or equal of given element, if such elements are not present in set it returns null.
Code:
ExampleOfHigherMethod.java
import java.util.Iterator; import java.util.NavigableSet; import java.util.TreeSet; public class ExampleOfHigherMethod { public static void main(String[] args) { NavigableSet obSet = new TreeSet(); obSet.add(2); obSet.add(3); obSet.add(4); obSet.add(5); obSet.add(6); Iterator obIterator = obSet.iterator(); System.out.println("Elements of navigableset."); while (obIterator.hasNext()) { System.out.print(obIterator.next() + " "); } System.out.println("\nHigher element : " + obSet.higher(5)); } }Output:
Elements of navigableset. 2 3 4 5 6 Higher element : 6 |
Download this code.
[ 0 ] Comments