What is the output of the following code.
public class Main { public static void main(String[] args) { String switchValue = "1"; switch (switchValue) { case "1": System.out.println("in case 1"); case "2": System.out.println("in case 2"); case 2 : System.out.println("in case int 2"); // Compilation error: incompatible types default: System.out.println("in default"); } } }
Compile time error Type mismatch: cannot convert from int to String
You cannot use integer value in case for String type.