Grammatically
Java is almost perfect, i.e., if one is tought a section, one's instinct comes into play in other sections.
But in some scenarios instinct fails, like
1.
Can anyboby change the value iOb refers? No, because iOb is final and Integer objects are immutable. So following must compile.
But the above doesn't compile. The argument is that case needs constants and iOb is an object and can be changed. Well! Contents of objects reffered by final variable can change. But, but, but, if the object is not immutable.
Here nobody can change the value of
iOb, so it can be considered in
case. But compiler treats it as other non-immutable objects.
2.
To make the compiler happy we have make variable i a compile time constant
so not even the following works
So it is compiler's own way to work satisfying its instinct.
If anyone has such kind of examples, please post them.
Those will help Java Programmers especially
SCJP aspirants.