/** * @author mh, inspired by Jaime Nino, New Orleans, LA * @version 1.0 * @date 04.04.2002 * @package informatik2.hello * @class Hello4 */ // generally, the state of an object may vary over time public class Hello4 { public static void main (String[] argv) { Mouth mouth = new Mouth("Hello, World!"); mouth.say(); Mouth mund = new Mouth("Hallo, Welt!"); mund.say(); mund.say(); mouth.say(); mouth.say(); } // main } // Hello4 //--------------------- cut into two files ----------------------------- class Mouth { public Mouth (String thought) { what = thought; count = 0; } // Mouth public void say() { count++; System.out.println("(" + count + ") " + what); } // say private String what; private int count; } // Mouth