简体   繁体   English

Java hashmap键值迭代器

[英]Java hashmap key value iterator

I have a hashmap when i am printing this hashmap the output is like this 当我打印这个hashmap时,我有一个hashmap,输出是这样的

{KEY_CH_UP=KEY_CH_UP, KEY_PANEL_CH_UP=KEY_PANEL_CH_UP, KEY_7=KEY_7, KEY_6=KEY_6, KEY_5=null}

Now i want to get all the keys which is having 现在我想得到所有的钥匙

values == null ;

Iterate over the like below and check if the value is null : 迭代下面的代码并检查值是否为null:

Map<String, String> map = new HashMap<String, String>();
        for(Map.Entry<String, String> en: map.entrySet()){
            if(en.getValue()==null){
                System.out.println(en.getKey());
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM