Java, Java8, Java21, Java17, Migration.
preview feature. Java 13 added a new yield construct to return a value from switch statement. With Java 14, switch expression now is a standard feature. public static String getDayType(String day) { var result = switch (day) { case "Monday", "Tuesday", "Wednesday","Thursday", "Friday": yield