Ravi,
its does not compile because: compiler is not smart enogh to understand
x++ (as method variable will not automatically initialized), see initially x was not initialized. and compiler does not undersand
value of y so it things "if" block may not pass so x would not have initialized at all. Hence, it gets compiler error. But if you put { after if statement and close } after x++ it will work.