您的位置:首页 > 编程语言 > Java开发

java map 的用法

2016-01-01 20:42 381 查看
import java.util.*;
public class MapKeyWord {
public static void main(String[] args) {
Map m1 = new HashMap();
Map m2 = new TreeMap();

m1.put("one",new Integer(1));
m2.put("two",new Integer(2));

m2.put("A",new Integer(1));
System.out.println(m1.size());
System.out.println(m2.size());

System.out.println(m1.containsKey("one"));
System.out.println(m1.containsValue(1));

int i = ((Integer)m1.get("one")).intValue();
System.out.println("i = " + i);

Map m3 = new HashMap(m1);
m3.putAll(m2);
System.out.println(m3);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: