Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search a HashMap in an ArrayList of HashMap

Tags:

java

I have an ArrayList of HashMap. I want to search a HashMap in it but unable to find a way to achieve this. Please suggest me how it can be done? Thanks.

like image 502
Ashish Kumar Avatar asked Jul 10 '12 19:07

Ashish Kumar


1 Answers

Answer to your question the way i understood it!

for (HashMap<String, String> hashMap : yourArrayList)
    {
        // For each hashmap, iterate over it
        for (Map.Entry<String, String> entry  : hashMap.entrySet())
        {
           // Do something with your entrySet, for example get the key.
           String sListName = entry.getKey();
        }
    }

Your Hashmap might use other types, this one uses Strings.

like image 154
Lucas Arrefelt Avatar answered Sep 22 '22 22:09

Lucas Arrefelt