The root reason why switch can't use long in JAVA is that long conversion to int will lose precision and lead to inaccurate data, so JAVA switch has a logical rule of not allowing long.
The type of variable in switch statement can be: byte, short, int or char. starting from Java SE 7, the switch supports string String type and the case token must be a string constant or literal.
Extended Information
Switch cases have the following rules in java:
Switch statements can have multiple case statements. Each case is followed by a value and a colon to be compared.
The data type of the value in the case statement must be the same as the data type of the variable and can only be a constant or literal constant.
When the value of the variable is equal to the value of the case statement, the statements following the case statement begin execution until the break statement appears to jump out of the switch statement.
The switch statement terminates when the break statement is encountered. The program jumps to execution of the statement following the switch statement. The case statement does not have to contain a break statement. If a break statement does not occur, the program continues to execute the next case statement until a break statement occurs.
The switch statement can contain a default branch, which is usually the last branch of the switch statement (it can be anywhere, but last is recommended). Default is executed when the case statement has no value and the variables have equal values. the default branch does not require a break statement.
Reference: