package com.inmind.of04; import java.util.List; import java.util.Map; import java.util.Set; /* 在JDK9中对单列和双列集合,定义了一个静态方法of,它能快速创建出简单的集合,保证集合不变的 使用场景: 在业务编写时,可以设计为不能更改的固定值,营业中,打烊中,准备中 */ public class OfDemo11 { public static void main(String[] args) { //List的of方法 List list = List.of(1, 2, 3, 4, 5); System.out.println(list); //Set的of方法 Set sets = Set.of("1", "2", "3", "4", "5"); System.out.println(sets); //Map的of方法 Map map = Map.of(1, "张三", 2, "lisi", 3, "wangwu"); System.out.println(map); } }