Finding the key of HashMap which holds the lowest integer value

后端 未结 5 838
暖寄归人
暖寄归人 2021-01-21 21:07

I\'m creating an educational game for young students who needs to learn the most common words. On random I pick three words of the list, show them on the screen, play an audio r

5条回答
  •  终归单人心
    2021-01-21 21:56

    i made this, it can hold multiple keys=

    HashMaphashmap_original=new HashMap<>();
            hashmap_original.put("key_1",1);
            hashmap_original.put("key_2",4);
            hashmap_original.put("key_3",1);
            hashmap_original.put("key_4",3);
    
            HashMaphashmap_result=new HashMap<>();
            int int_minium_value = 9999; //put a maxium value that u know your code it wont pass it
            for (String String_key:hashmap_original.keySet()) {
                int int_compare_value=hashmap_original.get(String_key); //get the value
    
                if (int_compare_value

提交回复
热议问题