Map集合概述和特点
- Map 集合概述
interface Map<K,V> K:键的类型 V:值得类型
将键映射到值的对象;不能包含重复得键;每个键可以映射到最多一个值
举例:学生的学号和姓名
itheima001 林青霞
itheima002 张曼玉
itheima003 王祖贤
创建Map集合的对象
多态的方式
具体的实现类HashMap
package common.Map;
import java.util.HashMap;
import java.util.Map;
public class mapDemo {
public static void main(String[] args) {
Map<String,String> m1 = new HashMap<String,String>();
m1.put("ithema001","林青霞");
m1.put("ithenma002","呜呜呜");
m1.put("itheima003","aaa");
m1.put("itheima003","bbb");
System.out.println(m1);
}
}