I was going through some Java tutorials in a book and ran across code like this:
private void theMethod( MyObject table )
{
SomeObject item1 = table.add(0,0,0,"Item 1");
{
item1.setWhatever = false;
item1.setSomething = 15;
}
// More code here...
}
What is the purpose of the braces following the variable definition?
I use this braces sometimes in group when I’m using a lot of local variables. This way, they are out of scope and I can create variables with the same name.
I can’t find immediately a good example, but I mean something like this: