The new features and the null

Report a typo

What will happen if you run this code using the new features?

public class SwitchPatternMatchingDemo {
    public static void main(String[] args) {
        String str = null;
        nullDemo(str);
    }

    static void nullDemo(String s) {
        switch (s) {
            case "null"  -> System.out.println("null case");
            case "Hello" -> System.out.println("Hello");
            case "Hi"    -> System.out.println("Hi");
            default      -> System.out.println("No Match!");
        }
    }
}
Select one option from the list
___

Create a free account to access the full topic