I wrote following program,it compiles and runs fine.But I was expecting compilation error for {} I am not able to undestand why does Java allows to have {} inside a method? Is it treated as Instance Initializer block?
Jon Dornback
Ranch Hand
Joined: Apr 24, 2002
Posts: 137
posted
0
it's perfectly legal to have a code block within a code block. i don't think it is commonly used, but the main effect is to limit the scope. the code below shows an example of how it works:
use the [CODE] tags - it makes it much easier for people to help you.
Ron Newman
Ranch Hand
Joined: Jun 06, 2002
Posts: 1056
posted
0
Also, empty code blocks are perfectly legal, and occasionally useful (for instance, to act as placeholders for future code).