3

How can i take all variables with tag URL for example?

Of this kind of variable: ArrayList<HashMap<String, String>>?

1
  • Why would you need a List of Maps? The properties of a URL can be expressed just as a Map Commented Dec 30, 2013 at 1:01

1 Answer 1

5

This is example for log all key and value in hashmap

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));
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.