This will compile
class X
{
public static void main(String args[])
{
{
int a = 2;
}
{
int a = 3;
}
}
}
This won't
class X
{
public static void main(String args[])
{
int a = 2;
{
int a = 3;
}
}
}
I expected both to compile (maybe it is the way C works?). What is the reason because it is not possible to declare a variable in a block with the same name of one in the outer block?