A block is any piece of code surrounded by {}s. When a block is exited, any variables declared within the block are recycled (See Variable Scope). Blocks can hold methods, loops, separate blocks or otherwise. The following code contains four blocks:

public class ClassHere {   //first block
  public static void main(String[] args) {   //second block
    int a = 0;
    for(int i = 0; i < 10; i++) {   //third block
      a = change(a);
  public static int change(int a) {   //fourth block
    a += 2;
    return a;

Block(s) Visual

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License