import java.util.*;
class Main{
public static void main
(String args
[]) { sample1();
sample2();
}
static void sample1() {
ArrayList
<HashMap
<String, String
>> arrayMap
= new ArrayList
<HashMap
<String, String
>>();
map.put("key0", "value0");
arrayMap.add(0, map);
map.put("key1", "value1");
arrayMap.add(1, map);
System.
out.
println("sample1:"); System.
out.
println(arrayMap.
get(0).
get("key0")); System.
out.
println(arrayMap.
get(1).
get("key1")); System.
out.
println(arrayMap.
get(1).
get("key0")); }
static void sample2() {
ArrayList
<HashMap
<String, String
>> arrayMap
= new ArrayList
<HashMap
<String, String
>>(); HashMap
<String, String
>map1
= new HashMap
<String, String
>(); HashMap
<String, String
>map2
= new HashMap
<String, String
>();
map1.put("key", "value0");
arrayMap.add(0, map1);
map2.put("key", "value1");
arrayMap.add(1, map2);
System.
out.
println("sample2:"); System.
out.
println(arrayMap.
get(0).
get("key")); System.
out.
println(arrayMap.
get(1).
get("key")); }
}
/* end */
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgTWFpbnsKICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgYXJnc1tdKSB7CiAgICBzYW1wbGUxKCk7CiAgICBzYW1wbGUyKCk7CiAgfQogIHN0YXRpYyB2b2lkIHNhbXBsZTEoKSB7CiAgICBBcnJheUxpc3Q8SGFzaE1hcDxTdHJpbmcsIFN0cmluZz4+IGFycmF5TWFwID0gbmV3IEFycmF5TGlzdDxIYXNoTWFwPFN0cmluZywgU3RyaW5nPj4oKTsKICAgIEhhc2hNYXA8U3RyaW5nLCBTdHJpbmc+bWFwID0gbmV3IEhhc2hNYXA8U3RyaW5nLCBTdHJpbmc+KCk7CgogICAgbWFwLnB1dCgia2V5MCIsICJ2YWx1ZTAiKTsKICAgIGFycmF5TWFwLmFkZCgwLCBtYXApOwogICAgbWFwLnB1dCgia2V5MSIsICJ2YWx1ZTEiKTsKICAgIGFycmF5TWFwLmFkZCgxLCBtYXApOwoKICAgIFN5c3RlbS5vdXQucHJpbnRsbigic2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