import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
public class Test {
public static void main(String[] args) {
Map tree = new TreeMap();
Map linked = new LinkedHashMap();
Map hash = new HashMap();
System.out.println("tree :"+buildMap(tree));
System.out.println("link :"+buildMap(linked));
System.out.println("hash :"+buildMap(hash));
}
private static Map buildMap(Map map){
map.put("0", "a");
map.put("e", "b");
map.put("4", "s");
map.put("3", "c");
return map;
}
}
结果:
tree :{0=a, 3=c, 4=s, e=b}
link :{0=a, e=b, 4=s, 3=c}
hash :{3=c, 0=a, 4=s, e=b}