This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
The reason the first code gives error is.....
"a" is non-final varible means it can change its value later....
And the compiler know that if the if condition fails "b" will not be initilaized.So error says "using before initilzing"
In the second case "a" in final and compiler can be sure that the value will not change and the "b" variable WILL be initialized
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !