sorry if this is an stupid question or anything; but I'm having a problem looping through two different objects in java. one of them is a hashmap and the other one is an arraylist. the objects look something like this:
Map<String,Integer> myMap = new HashMap();
ArrayList<String> myArray = new ArrayList();
I need to loop through each item in "myArray" and check if the item exists in one of "myMap"'s keys. I actually know how to do that but the way I do it, contains a lot of unnecessary looping and I want to know if there is an faster way to do it or not. the way I do it:
Map<String,Integer> myMap = new HashMap();
ArrayList<String> myArray = new ArrayList();
for(String i:myArray) {
for(String j:myMap.keySet()) {
if(i == j) {
myMap.put(j, myMap.get(j) + 1)
}
}
}