posted 18 years ago
Hi,
u wont believe,i had this doubt haunting my mind for quite sometime,until i tried out a few codes..u call a variable a compile time constant if the compiler knows the value of that variable during compilation rather than at runtime as in most other cases..from ur code,
final int a=1: //compile time constant cos the compiler knows its value during compilation
final int b; //all the compiler knows is tht it is a final variable ,,the value is assigned only during runtime if u do not assign it in the same line it is declared..
b =2; // no use,compilation is over..so b gets the value only at runtime..
Since there is a limitation to switch case variables that they be final and int/int compatible,the compiler should be able to resolve its value at compile time itself to prevent compilation error.
hope i did not confuse u further..!