

- package day01;
-
- import java.util.*;
-
- public class Mapday1 {
-
- public static void main(String[] args) {
-
- /*
- HashMap 无序 不重复,会覆盖前面 无索引
- */
- System.out.println("--------------------");
- Map<String, Integer> map = new HashMap<>();
- map.put("wwx1", 1);
- map.put("wwx2", 2);
- map.put("wwx3", 3);
-
- //调用Map集合提供entrySet方法,把Map集合转换成键值对类型的Set集合
- Set<Map.Entry<String, Integer>> entries = map.entrySet();
- for (Map.Entry<String, Integer> entry : entries) {
- String key = entry.getKey();
- Integer value = entry.getValue();
- System.out.println(key+"-->>"+value);
- }
-
-
- }
- }
