Skip to content

Instantly share code, notes, and snippets.

@duncanmak
Created August 18, 2010 23:13
Show Gist options
  • Select an option

  • Save duncanmak/536498 to your computer and use it in GitHub Desktop.

Select an option

Save duncanmak/536498 to your computer and use it in GitHub Desktop.
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