Alex Rivera | Logout

What do curly braces in Java mean by themselves?

Asked 2008-10-27T19:13:12.400
87

I have some Java code that uses curly braces in two ways

// Curly braces attached to an 'if' statement:
if(node.getId() != null)
{
    node.getId().apply(this);
}

// Curly braces by themselves:
{
    List<PExp> copy = new ArrayList<PExp>(node.getArgs());
    for(PExp e : copy)
    {
        e.apply(this);
    }
}
outAMethodExp(node);

What do those stand-alone curly braces after the first if statement mean?

Edit
Report

1 Answer

0

I think they just define an unnamed level of scope.

answered 2008-10-27T19:14:51.290

Your Answer