18 March 2020

Java 14 released: switch expressions

    switch (day) {
        case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
        case TUESDAY                -> System.out.println(7);
        case THURSDAY, SATURDAY     -> System.out.println(8);
        case WEDNESDAY              -> System.out.println(9);
    }

    int numLetters = switch (day) {
        case MONDAY, FRIDAY, SUNDAY -> 6;
        case TUESDAY                -> 7;
        case THURSDAY, SATURDAY     -> 8;
        case WEDNESDAY              -> 9;
    };
    Also:
    • NullPointerExceptions can now report which variable was null, but this is off by default. To enable use the commond line option -XX:+ShowCodeDetailsInExceptionMessages.
    • Java 14 says goodbye to its Sun origins by deprecating the Solaris (OS) and SPARC (processor) ports
    • some preview and incubator features, scheduled for future releases

    No comments:

    Post a Comment