How to check if TreeMap> contains a value? in Java

前端 未结 3 393
刺人心
刺人心 2021-01-28 14:39

I\'m just wondering how to check if TreeMap> contains a value in Java? For Example:

/*I have TreeMap> map with these element         


        
3条回答
  •  面向向阳花
    2021-01-28 15:19

    public boolean valueExists(String value){
    for(Map.Entry> entry : treeMap.entrySet()) {
      String key = entry.getKey();
      ArrayList values = entry.getValue();
      for (String str:values){
         if (value.equals(str)){
             return true;
         }
      }
    
    }
    return false;
    } 
    

提交回复
热议问题