我如何使用标记URL获取所有变量?
这种变量:ArrayList<HashMap<String, String>>
?
答案 0 :(得分:5)
这是hashmap中的log all键和值的示例
ArrayList<HashMap<String, String>> arrayList = new ArrayList<HashMap<String,String>>();
HashMap<String, String> h1 = new HashMap<String, String>();
h1.put("h1_key_1", "h1_value_1");
h1.put("h1_key_2", "h1_value_2");
arrayList.add(h1);
HashMap<String, String> h2 = new HashMap<String, String>();
h2.put("h2_key_1", "h2_value_1");
h2.put("h2_key_2", "h2_value_2");
arrayList.add(h2);
for (HashMap<String, String> hashMap : arrayList) {
System.out.println(hashMap.keySet());
for (String key : hashMap.keySet()) {
System.out.println(hashMap.get(key));
}
}