Java Programming/Blocks

From Wikibooks, open books for an open world
< Java Programming
Jump to: navigation, search

Java has a concept called block that is enclosed between the { and } characters, called curly braces. A block executed as a single statetement, and can be used where a single statetement is accepted.

After a block is executed all local variables defined inside the block is discarded, go out of scope.

{
...
 // -- This is a block ---
}

Blocks can be nested:

{
...
  {
     // -- This is a nested block ---
  }
}