//******************************************************************** // CountInstances.java Author: Lewis and Loftus // // Demonstrates the use of the static modifier. //******************************************************************** class CountInstances { //----------------------------------------------------------------- // Creates several MyClass objects and prints the number of // objects that were created. //----------------------------------------------------------------- public static void main (String[] args) { MyClass obj; for (int scan=1; scan <= 10; scan++) obj = new MyClass(); System.out.println ("Objects created: " + MyClass.getCount()); } }