import java.util.HashMap;
import java.util.Map;
public class Test{
public static void main(String [] args){
Map<String,Integer> scores = new HashMap<String,Integer>();
scores.put("Jim",100);//1.添加数据,其中"Jim"是key,100是value
scores.put("Jim",80);//Map集合中key不允许重复,重复的话以最后一个为主
scores.put("Kate", 90);
int score = scores.get("Jim");//2.获取指定key对应的value,即获取Jim的成绩
System.out.println(score);
int size = scores.size();//3.获取Map中键值对的个数
System.out.println(size);
//scores.clear();//4.清空
size = scores.size();
System.out.println(size);
boolean flag = scores.isEmpty();//5.判断Map集合是否为空
System.out.println(flag);
scores.replace("Jim", 0);//6.替换指定key位置的value的值
score = scores.get("Jim");
System.out.println(score);
}
}