用HashMap创建jString,ArrayList的键值对用entrySet遍历
package 随机点名器;
import java.util.*;
public class Test1 {
public static void main(String[] args){
HashMap<String,ArrayList<String>> m=new HashMap<>();
ArrayList<String> hl=new ArrayList<>();
hl.add("哈尔滨");
hl.add("牡丹江");
ArrayList<String> wh=new ArrayList<>();
wh.add("武陵");
wh.add("汉水");
m.put("武汉",wh);
m.put("黑龙江",hl);
Set<Map.Entry<String, ArrayList<String>>> entries = m.entrySet();
for(Map.Entry<String,ArrayList<String>> entry:entries){
String s=entry.getKey();
ArrayList<String> ss=entry.getValue();
System.out.println(s+"="+ss);
}
}
}
标签:对用,jString,HashMap,ArrayList,entrySet,wh,add,键值,hl From: https://www.cnblogs.com/luo9tian/p/17793721.html