Type checking syntax

Report a typo

What is the output of this application? Write the whole output line without quotation marks.

public class SwitchPatternMatchingDemo {
    public static void main(String[] args) {
        Object obj = "-100";
        switchTypeCheckingDemo(obj);
    }

    static void switchTypeCheckingDemo(Object o) {
        switch (o) {
            case Integer i && i == -100 -> System.out.printf("int: %d, the value is negative", i);
            case String s && s.equals("-100") -> System.out.printf("String: %s, the value is negative", s);
            default -> System.out.println("No Match!");
        }
    }
}
Enter a short text
___

Create a free account to access the full topic