美文网首页
hashMap.replaceAll

hashMap.replaceAll

作者: felixfeijs | 来源:发表于2021-04-15 10:42 被阅读0次
    public static void main(String[] args) {
        Map<Object, String> hashMap = new HashMap<>();
        hashMap.put("a", "a");
        hashMap.put("b", "b");
        hashMap.put(null, null);
        hashMap.replaceAll((k, v) -> {
                    if (v != null) {
                        return v.toUpperCase();
                    }
                    return v;
                }
        );
        System.out.println(hashMap);
    }

相关文章

网友评论

      本文标题:hashMap.replaceAll

      本文链接:https://www.haomeiwen.com/subject/sujclltx.html