/* simple class that is used by StaticUser to demonstrate a class with static variables and methods */ public class StaticExample { private int x; // non static instance datum private static int y; // static class-wide datum public StaticExample() { x=y=0; // no-arg constructor initializes both data to 0 } public StaticExample(int x) { this.x=x; // another constructor which initializes the non-static datum y=0; // while initializing the class-wide datum to 0 } public void change(int x) { this.x=x; // setter for instance datum, increments class-wide datum y++; // so in effect, y is counting the number of times we change any x } public void inc() // increment both x and y { x++; y++; } public static int getY() // static method to return y { return y; } }