Map转ArrayList记录一下

Map map = new HashMap();
map.put("a", "a1");
map.put("b", "b1");
map.put("c", "c1");
List listKey = new ArrayList();
List listValue = new ArrayList();
Iterator it = map.keySet().iterator();
while(it.hasNext()){
String key = it.next().toString();
listKey.add(key);
listValue.add(map.get(key));
}
System.out.println("   have a look");
for(int i = 0;i System.out.print("key:"+listKey.get(i));
System.out.println("       value:"+listValue.get(i));
}

你可能感兴趣的:(Java类)