package 容器类;
import java.util.*;
// 所有的用法请参考 Api 文档
class Am{
private int a;
public Am(int a){
this.a = a;
}
public int getA() {
return a;
}
}
public class map1 {
public static void main(String[] args) {
HashMap hm = new HashMap<Integer,Am>();
hm.put(1,new Am(5)); //放入映射关系
hm.put(2,new Am(5));
Am am = (Am)hm.get(1); //提取映射关系
System.out.println(am.getA());
System.out.println(hm.containsKey(1));
System.out.println(hm.size());
hm.remove(1); // 删除映射关系
System.out.println(hm.size());
}
}
map的使用
最新推荐文章于 2022-07-17 19:43:48 发布