import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class HashMapSync {
static List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
static HashMap<String, Object> map1 = null;
public static void main(String[] args) {
map1= new HashMap<String, Object>();
map1.put("ItemId", 1);
map1.put("ItemName", "wang");
list.add(map1);
HashMap<String, Object> map2 = new HashMap<String, Object>();
map2 = list.get(0);
map2.put("ItemName", "li");
System.out.println("id="+list.get(0).get("ItemId")+"/"+"name="+list.get(0).get("ItemName"));
}
}
输出结果为:
id=1/name=li