取得key和value:
package com.gwolf;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class TestDemo {
public static void main(String[] args) {
Map map = new HashMap<>();
map.put(1,"hello");
map.put(2,"world");
Set> set = map.entrySet();
Iterator> iterator = set.iterator();
while (iterator.hasNext()) {
Map.Entry me = iterator.next();
System.out.println(me.getKey() + "=" + me.getValue());
}
}
}