// This is designed to illustrate several important concepts, including the use // of static vs. non-static variables and methods, the use of multiple constructors, // and the use of accessors (setters and getters) with private data. public class Thing { // Static data private static int objectCount = 0; // Getter for the private objectCount variable. // Note that it has no setter. We don't want it changed // anywhere but from within this class. public static int getObjectCount() { return objectCount; } // Instance variables private int a = 5; private int b = 7; // Constructors public Thing() { objectCount++; }; public Thing(int alpha) { a = alpha; objectCount++; } public Thing(int alpha, int beta) { a = alpha; b = beta; objectCount++; } // Instance methods // The first 2 are setters and the next 2 are getters. public void setA(int alpha) { a = alpha; } public void setB(int beta) { b = beta; } public int getA() { return a; } public int getB() { return b; } public void print(String s) { System.out.println(s + ": " + a + " " + b); } }