I'm studying for my SCJP2 certification and ran across this code on a quiz:
Since i is an int and b is a byte, I assumed that the compiled would complain about the assignment. The quiz answer says it works and I tried it on my machine (Wintel) and it sure-enough did!
I can only assume that the compiler is treating i as a constant and allowing the assignment because i is marked final. I haven't found any reference to this behavior in any of the
Java books I've seen. Can anybody point me to a good reference that might cover it?
Thanks!
------------------
TANSTAAFL
(edited by Cindy to add formatting)
[This message has been edited by Cindy Glass (edited May 30, 2001).]