You will be getting this error when you try to use
some expression or variable next to case:. See
following code for more clarifications.
class SwitchTest
{
static int x=0;
private static int getSomeInt()
{
return 2;
}
public static void main(String str[])
{
switch (getSomeInt()){
//case x: gives same error.
case: 1 // works fine.
System.out.println(1);
break;
case 2:
System.out.println(2);
break;
default:
System.out.println("default");
}
}
}