点击运行
import java.util.HashMap; public class Main { public static void main(String[] args) { // 创建一个 HashMap HashMap
sites = new HashMap<>(); // 往 HashMap 添加一些元素 sites.put(1, "Google"); sites.put(2, "Jiyik"); sites.put(3, "Taobao"); System.out.println("sites HashMap: " + sites); // 将所有的值更改为大写 sites.replaceAll((key, value) -> value.toUpperCase()); System.out.println("Updated HashMap: " + sites); } }
运行结果 :
正在执行...