public class StaticUser { public static void main(String[] args) { StaticExample s1=new StaticExample(); // create 3 objects, note that y will be (re)set to 0 each time StaticExample s2=new StaticExample(5); StaticExample s3=new StaticExample(10); s1.inc(); // inc increments both, so s1's x and the class-wide y are both 1 s2.change(15); // s2's x is now 15, class-wide y is 2 s3.change(22); // s3's x is now 22, class-wide y is 3 s3.inc(); // increment s3's x to 23, class-wide y is now 4 System.out.println(StaticExample.getY()); // returns the class-wide y, 4 } }