What will be the result of compilation and execution of the following code:
public class Test {
public static void main(String[] s){
long c = 1;
switch(c)
{
case 1: c = 3; break;
case 3: c = 4; break;
}
System.out.println(c);
}
}
A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types, the String class (since JDK 7), and a few special classes that wrap certain primitive types: Character, Byte, Short, and Integer.
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать