Java tutorial
//package com.java2s; import java.util.Comparator; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; public class Main { public static <K, V> TreeMap<K, V> createTreeMap() { return new TreeMap<K, V>(); } public static <K, V> TreeMap<K, V> createTreeMap(Comparator<? super K> comparator) { if (comparator == null) { return null; } return new TreeMap<K, V>(comparator); } public static <K, V> TreeMap<K, V> createTreeMap(Map<? extends K, ? extends V> map) { if (map == null) { return null; } return new TreeMap<K, V>(map); } public static <K, V> TreeMap<K, V> createTreeMap(SortedMap<K, ? extends V> map) { if (map == null) { return null; } return new TreeMap<K, V>(map); } }