import java.util.*;
public class Ex_HashMap{
public static void main(String args[]){
HashMap map = new HashMap();
map.put("a","abcd");
map.put(new Integer(200), new Integer(2));
map.put(new Object(),"object");
map.put(null, null);
System.out.println(map.toString());
System.out.println("key =A: "+ map.get("a"));
System.out.println("key =B: "+ map.get("B"));
System.out.println("key =new Integer(100): "+map.get(200));
}
}
{null=null, a=abcd, 200=2, java.lang.Object@15db9742=object}
key =A: abcd
key =B: null
key =new Integer(100): 2
沒有留言:
張貼留言