Things you shouldn’t be able to do in Java #312
The Fishbowl: When is a constant not a constant?. Charles Miller posts one of those “Guess what this code does” challenges, and it’s in Java. I prayed that I wasn’t right, but was sickened when I ran the code and discovered the worst. Ugh. I’m not all that surprised as sittingDuck is not really a constant, more like a variable which has been initialised to a specific value. Actually, scratch that. I just tried declaring sittingDuck as final
and it still works as before. So much for objects as constants.