package com.xiaoye;
import java.security.KeyStore.Entry;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.junit.Test;
public class ListMap {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
@Test
public void function() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("1", "张三");
map.put("2", "李四");
map.put("3", "王五");
list.add(map);
for (Map<String, Object> map1 : list) {
Iterator<Map.Entry<String, Object>> itertor = map1.entrySet().iterator();
while (itertor.hasNext()) {
Map.Entry<String, Object> entry = itertor.next();
System.out.println(entry.getKey() + " , " + entry.getValue());
}
}
}
}
List 中存放Map对象,与遍历map中的数据
最新推荐文章于 2024-08-05 03:58:42 发布