使用双括号
HashMapcodeStyle = new HashMap (){{ put("java","easy"); put("python","easy"); put("c","hard"); }};
使用Guava
MapstudentAge = ImmutableMap.of("Jim", 10, "Kate", 11, "Lucy", 9);
JDK 9
Map.of("Hello", 1, "World", 2); // 不可变集合
2. List 、Set
使用JDK8 stream
Listlist = Stream.of("TV", "MOBILE", "MOTOR").collect(Collectors.toList()); List set = Stream.of("TV", "MOBILE", "MOTOR").collect(Collectors.toSet());



