一、record类
创建:
public record Student(Integer id,String name,String email,Integer age) {
}
测试:
@Test
public void test()
{
Student lisi = new Student(1,"李四","123@lisi.com",15);
System.out.println(lisi);
//获取属性:通过public访问器,获取属性值(只读)
Integer id = lisi.id();
String name = lisi.name();
}
二、Switch
三、文本块
四、密封类sealed
申明:public sealed class 类名 permits 子类1,子类N{}