jtulach@70: package org.apidesign.hello; jtulach@70: jtulach@70: public class ThreeWaysToUseHello { jtulach@70: jtulach@70: // BEGIN: hello.say jtulach@70: public static void sayHello() { jtulach@70: Hello hello = new Hello(); jtulach@70: hello.hello(); jtulach@70: } jtulach@70: // END: hello.say jtulach@70: jtulach@70: // BEGIN: hello.subclass jtulach@70: private static class MyHello extends Hello { jtulach@70: @Override jtulach@70: public void hello() { System.out.println ("Hi"); } jtulach@70: } jtulach@70: // END: hello.subclass jtulach@70: jtulach@70: // BEGIN: hello.supercall jtulach@70: private static class SuperHello extends Hello { jtulach@70: @Override jtulach@132: public void hello() { jtulach@132: super.hello(); jtulach@132: System.out.println("Hello once again"); jtulach@132: } jtulach@70: } jtulach@70: // END: hello.supercall jtulach@70: jtulach@70: /** shows more ways to use a class. prints four various messages */ jtulach@70: public static void main(String[] args) { jtulach@70: sayHello(); jtulach@70: new MyHello().hello(); jtulach@70: new SuperHello().hello(); jtulach@70: } jtulach@70: }