标签:get sys shc 多个 one hash cell 获取值 比较
Map接口中键和值一一映射. 可以通过键来获取值。
序号 |
方法描述 |
1 |
void clear( ) |
2 |
boolean containsKey(Object k) |
3 |
boolean containsValue(Object v) |
4 |
Set entrySet( ) |
5 |
boolean equals(Object obj) |
6 |
Object get(Object k) |
7 |
int hashCode( ) |
8 |
boolean isEmpty( ) |
9 |
Set keySet( ) |
10 |
Object put(Object k, Object v) |
11 |
void putAll(Map m) |
12 |
Object remove(Object k) |
13 |
int size( ) |
14 |
Collection values( ) |
Map<String, Object> m1 = new HashMap<String, Object>(); Map<String, Object> m2 = new HashMap<String, Object>(); m1.put("aaa", "bb"); m1.put("ab", "cccc"); m1.put("ddd", "ddd"); System.out.println(m1); System.out.println("------------1---------------"); System.out.println(m1.containsKey("aaa")); System.out.println(m1.entrySet()); System.out.println("aaa".equals(m1.containsKey("aaa"))); System.out.println("bb".equals(m1.get("aaa"))); System.out.println(m1.get("aaa").hashCode()); System.out.println(m1.isEmpty()); System.out.println(m1.keySet()); m2.putAll(m1); m2.put("222", "222"); System.out.println(m2); m2.remove("222"); m2.remove("333"); System.out.println(m2); System.out.println(m2.size()); System.out.println(m2.values());
执行结果:
{aaa=bb, ddd=ddd, ab=cccc} ------------1--------------- true [aaa=bb, ddd=ddd, ab=cccc] false true 3136 false [aaa, ddd, ab] {222=222, aaa=bb, ddd=ddd, ab=cccc} {aaa=bb, ddd=ddd, ab=cccc} 3 [bb, ddd, cccc]
标签:get sys shc 多个 one hash cell 获取值 比较
原文地址:http://www.cnblogs.com/xuange306/p/6636103.html