文章目录 声明 声明 # 方式一:静态方法of Map<String, Integer> scores = Map.of("a", 2, "b", 3, "c", 5); # 方式二:静态方法ofEntries import static java.util.Map.entry; Map<String, Integer> scores2 = Map.ofEntries( entry("a", 2), entry("b", 3), entry("c", 5)); # 输出:{a=2, b=3, c=5}