Posts Tagged - java12

Changes in Java12

Switch expression

It has been revamped to act as an expression. It removes the usage of break.

switch(day) {
  case SATURDAY, SUNDAY -> System.out.println(1);
  case TUESDAY, FRIDAY -> System.out.println(2);
  case THURSDAY, MONDAY -> System.out.println(3);
  case WEDNESDAY -> System.out.println(4);
}

Read More