To continue from yesterday'sthread.... Why don't you write one for us that tests this?
Have it demonstrate what will happen if you try to reassign a final variable. Show us how you can change the data contained by the object to which the variable is assigned (for example: change the value of a StringBuilder object).
Tell us what you expected the program to do. Tell us what happened when you tried to compile it in both cases. Tell us what happened when you ran this program. [ April 09, 2008: Message edited by: Ben Souther ]
and... what error message did the compiler give you when it failed? (I'm assuming that you got past the typos like 'statci' and the missing curly brace at the end.) [ April 09, 2008: Message edited by: Ben Souther ]
Despite what Ben said above, your code doesn't compile because you try to assign final f1 to another object which is referred by f2 in line if (f1==f2) f1=f2. This line will give output compiler error.
quote:Final references variables cannot refer to different object once the object has assigned to the final variable.. The data can be modified ..
the answer of your question is from explanation that you have quoted above. it gives output 6 because you modified data/state from method Fizswitch. The original value is 5 and after modified it gives you 6. hope this help.