1206yaya
6/14/2015 - 12:05 AM

Collectionについて TreeMapSample

Collectionについて TreeMapSample

class TreeMapSample {
	public static void main(String[] args) {
		NavigableMap<String, String> map = new TreeMap<String, String>();
		map.put("1111", "ItemA");
		map.put("2222", "ItemB");
		map.put("2500", "ItemB-1");
		map.put("3333", "ItemC");
		map.put("4444", "ItemD");
		String key = "2000";

		if (map.containsKey(key)) {
			System.out.println("get() : " + map.get(key));
		} else {
			System.out.println("higherKey() : " + map.higherKey(key));
			System.out.println("lowerKey() : " + map.lowerKey(key));
		}
		NavigableMap<String, String> sub = map.subMap("2000", true, "3500",
				true);
		System.out.println("2000よりも大きく3500よりも小さい : " + sub);
		Object c = new Object();
		ArrayList<String> a = new ArrayList<String>();
	}
}