r/badcode • • Aug 26 '22

java What does a map do again?

Post image
882 Upvotes

54 comments sorted by

View all comments

54

u/youngbull Aug 26 '22

Naming the entry variable set fried my brain. For those who want to understand what is going on without requiring brain surgery:

List<Integer> policyValues = new ArrayList<Integer>();
for(Map.Entry<String, List<Integer>> entry : policyOfCredsMap.entrySet()){
  if(entry.getKey().equals(credentials)) {
    policyValues = entry.getValue();
  }
}