hashMap.replaceAll

2021-04-15  本文已影响0人  felixfeijs
    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);
    }
上一篇 下一篇

猜你喜欢

热点阅读