Created
August 18, 2010 23:13
-
-
Save duncanmak/536498 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Test { | |
| public static abstract class Base { | |
| public Base (int x) { initialize (x); } | |
| protected String value; | |
| private void initialize (int x) { | |
| value = Integer.toString (x) + getFoo (); | |
| } | |
| public abstract String getFoo (); | |
| @Override | |
| public String toString () { return value; } | |
| } | |
| public static class Derived extends Base { | |
| public Derived (int x) { | |
| super (x); | |
| foo = "foo"; | |
| } | |
| private String foo; | |
| @Override | |
| public String getFoo () { return foo; } | |
| } | |
| public static void main (String [] args) | |
| { | |
| Derived d = new Derived (3); | |
| System.out.println (d); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment