public class MainClass { private static int x = 1; public static void main(String args[]) { MyClass hs1 = new MyClass(); hs1.x++; MyClass hs2 = new MyClass(); hs2.x++; hs1 = new MyClass(); hs1.x++; MyClass.x++; System.out.println("x = " + x); } } class MyClass{ static int x = 0; }