Code example for TreeSet

Methods: add, ceiling, floor

0
package ru.antonevane.ch7; 
 
import java.util.SortedMap; 
import java.util.TreeMap; 
import java.util.TreeSet; 
 
public class Navigatable { 
 
	public static void main(String[] args) {
		TreeSet<Integer> times = new TreeSet<Integer>();
		times.add(1545);
		times.add(1645);
		times.add(1945);
		 
 
		System.out.println(times.floor(1644));
		System.out.println(times.ceiling(1644));
 
		TreeMap<String, String> map = new TreeMap<String, String>();
		map.put("a", "ant");
		map.put("d", "dog");
		map.put("h", "horse");
 
		SortedMap<String, String> submap;
		submap = map.subMap("b", "g"); // #1 create a backed collection