I have the following HashMap
where the key
is a String
and the value
is represented by an ArrayList
:
HashMap<String, ArrayList<String>> productsMap = AsyncUpload.getFoodMap();
I also have another ArrayList<String> foods
implemented in my application.
My question is, What would be the best way to find out if my HashMap
contains a Specific String
from my second ArrayList
?
I have tried without success:
Iterator<String> keySetIterator = productsMap.keySet().iterator();
Iterator<ArrayList<String>> valueSetIterator = productsMap.values().iterator();
while(keySetIterator.hasNext() && valueSetIterator.hasNext()){
String key = keySetIterator.next();
if(mArrayList.contains(key)){
System.out.println("Yes! its a " + key);
}
}