HashMap Searching For A Specific Value in Multiple Keys

后端 未结 3 1723
别跟我提以往
别跟我提以往 2021-01-29 10:34

I\'m checking to see if a key in my HashMap exists, if it does, I also want to check to see if any other keys have a value with the same name as that of the original key I check

3条回答
  •  攒了一身酷
    2021-01-29 11:08

    As I understand your question, the values in your Map are List. That is, your Map is declares as Map>. If so:

    for (List listOfStrings : myMap.values()) [
      if (listOfStrings .contains(searchcourse) {
        // do something
      }
    }
    

    If the values are just Strings, i.e. the Map is a Map, then @Matt has the simple answer.

提交回复
热议问题