Final Variables
Declaring a variable with the final keyword makes it impossible to reinitialize that variable once it has been initialized with an explicit value (notice we said explicit rather than default). For primitives, this means that once the variable is assigned a value, the value can't be altered. For example, if you assign 10 to the int variable x, then x is going to stay 10, forever.
K&B BOOK PG 57.
So does this mean that without initialization, the final variable in the above source gets the value 0 assigned automatically, since its the default for primitves(here int), and receives the ability to modify it later
prints out a's value as 10.
But this
Is this valid.... Compile error is there.
If the value 10 was assigned in the first coding sample. why does the switch statement requires to initialize the variable at the same time??
Compile error :- TestKB.java:9: constant expression required
case b:
^