What does two consecutive blocks of code {}{} do? [duplicate]

It’s is just writing two different blocks of code in order to hide local variables.

From the answer to the question “Anonymous code blocks in Java”:

Blocks restrict variable scope.

public void foo()
{
    {
        int i = 10;
    }
    System.out.println(i); // Won't compile.
}

In practice, though, if you find yourself using such a code block then
it’s probably a sign that you want to refactor that block out to a
method.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)