I have two java snippets using a constant in a switch case:
final Integer s1=5;
int x=5;
switch(x){
case s1: **<== causes complilation error..**
System.out.println("hello");
}
The code below works fine as s1
is treated as a constant, whereas the code above does not work.
final int s1=5;
int x=5;
switch(x){
case s1: <=== ok s1 is constant
System.out.println("hello");
}
What is the difference between the above two declarations?