java遍历map

  1. ap<String, String> map = new HashMap<String, String>();
  2. Iterator<Entry<String, String>> it = map.entrySet().iterator();
  3. while (it.hasNext()) {
  4.     Entry<String, String> entry = it.next();
  5.    String key = entry.getKey();
  6.     String value = entry.getValue();
  7.     System.out.println("key: " + key);
  8.     System.out.println("value: " + value);
  9. }

你可能感兴趣的:(map)