在此次JDK13中,共更新了5个特性,下面对新特性做介绍。JDK13官方说明
五大新特性
一.表达式switch(二次预览):
switch新特性在JDK12已经进行预览,JDK13中二次预览,使用lamda表达式进行替换。
public class SwitchTest {
@Test
public void test1(){
Week day=Week.FRIDAY;
switch (day){
case MONDAY:
case TUESDAY:
case WEDNESDAY:
System.out.println("星期一或星期二或星期三");
case THURSDAY:
case FRIDAY:
System.out.println("星期四或星期五");
case SATURDAY:
System.out.println("星期六");
case SUNDAY:
System.out.println("星期日");
default:
throw new IllegalStateException("What day is it today"+day);
}
}
//jdk12新特性
public void test2(){
Week day=Week.FRIDAY;
switch