scope in Java

The scope of a variable is where the name can be used to refer to the entity. In other parts of the program the name may refer to a different entity, or to nothing at all. 
Trying to declare two variables with same name in same scope causes a compile time error.
```
class Main {
    public static void main(String[] args) {
        int i = 22;
        {
            int i = 11; // variable i is already defined in method main
            if (true) {
                int i = 0; // variable i is already defined in method main
            } 
        }
    }
}
```