import java.util.HashMap;
import java.util.Map;
public class Demo {
public static void main(String[] args) {
Map<Integer,Integer> m = new HashMap<Integer,Integer>();
m.put( 1 , 1 );
print(m);
m.put( 1 , 2 );
print(m);
}
private static void print(Map<Integer, Integer> m) {
for (Map.Entry<Integer, Integer> mm : m.entrySet())
System.out.println( "K: " +mm.getKey()+ ",V: " +mm.getValue());
}
}
//供参考,重新放一个相同的key,会自动覆盖value的。