Java Reference
In-Depth Information
Listing 5-13 demonstrates a navigable set based on a tree set.
Listing 5-13. Navigating a set of integers
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.TreeSet;
class NavigableSetDemo
{
public static void main(String[] args)
{
NavigableSet<Integer> ns = new TreeSet<>();
int[] ints = { 82, -13, 4, 0, 11, -6, 9 };
for (int i: ints)
ns.add(i);
System.out.print("ascending order: ");
 
Search WWH ::




Custom Search