public class Foo { public static int x = -1; private int y; // x, y accessible here // newX, z not accessible public Foo() { y = 1; System.out.print(x + " " + y); } // x, y accessible here // newX: a parameter, also a local variable // z: local variable // Both: accessible only inside the scope of the method public void setX(int newX) { int z = 0; } // x, y accessible here // newX not accessible // z: local to this method, not the same as the one in setX() public void anotherMethod() { int z = 1; } }