这个问题,看你的代码怎么规范。将数据库中取出的值存如map的value,再把value循环存入list。如果map的key值没有逻辑要求,可以将key字符串设置成迭代参数,如"0","1","2"等,循环如下:
for(int i=0;i
list.add(map.get(key));
}
Set keys = map.keySet();//所有的key的集合
List
//方法一、
HashMap map = new HashMap();
Set valueSet = map.entrySet();//hashMap
Iterator iterator = valueSet.iterator();
List list = new ArrayList();//值list
while(iterator.hasNext()){
Object object = iterator.next();
list.add(object);
}
//方法二、
HashMap map = new HashMap();
Set keySet = map.keySet();//hashMap
Iterator keyIterator = keySet.iterator();
List keyList = new ArrayList();//key list
List valueList = new ArrayList();//值 list
while(keyIterator.hasNext()){
Object object = keyIterator.next();
keyList.add(object);
valueList.add(map.get(object));
}