List>使用Java代码遍历以获取String,Object的值

时间:2022-06-07 19:18:16

List<Map<String,Object>>的结果集怎么使用Java代码遍历以获取String,Object的值?

package excel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class List1
{
public static void main(String[] args)
{

Map map = new HashMap<String, Object>();
map.put("1", "fds");
map.put("2", "valu");
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
for (Map<String, Object> m : list)
{
for (String k : m.keySet())
{
System.out.println(k + " : " + m.get(k));
}

}

}
}