利用自定义泛型,自己简单实现HashMap (二)

2014-11-24 11:30:17 · 作者: · 浏览: 14
am args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyHashMap map = new MyHashMap();

map.put("hello1", "world1");
map.put("hello2", "world2");

System.out.println(map);

Set set = map.keySet();
for (String string : set) {
System.out.println(string);
}

}

}

public class Test {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyHashMap map = new MyHashMap();

map.put("hello1", "world1");
map.put("hello2", "world2");

System.out.println(map);

Set set = map.keySet();
for (String string : set) {
System.out.println(string);
}

}

}
有图有真相,总结:HashMap就是自定义索引的Set


\