Magazine
 
Java Collections API
 
 


nSet.pollLast());
//After removing the last element, now get navigable
set
System.out.println(“Now navigable set: “ +
nSet.descendingSet()); }}


Output:


C:\javac>javac NavigableSetExample.java
C:\javac>java NavigableSetExample
Navigable set Example!
Ascending order navigable set: 10 20 30 50 80 100
Descending order navigable set: [100, 80, 50, 30, 20,
10]
Least element in Navigable set greater than or equal
to 35: 50
Greatest element in Navigable set less than or equal
to 35: 30
Navigable set whose elements are strictly less than
'40': [10, 20, 30]
Navigable set whose elements are greater than or
equal to '40': [50, 80, 100]
Remove element: 10
Now navigable set: [100, 80, 50, 30, 20]
Remove element: 100
Now navigable set: [80, 50, 30, 20]
C:\javac>
Java Collections API

 

 
July 2007 | Java Jazz Up |15
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 ,            Download PDF