Skip to content

Instantly share code, notes, and snippets.

@jnizet
Created January 1, 2018 11:07
Show Gist options
  • Save jnizet/bbea3b4072329cd7540d8c2a32fc7244 to your computer and use it in GitHub Desktop.
Save jnizet/bbea3b4072329cd7540d8c2a32fc7244 to your computer and use it in GitHub Desktop.
public abstract class OverridableFromConstructor {
OverridableFromConstructor() {
test();
}
protected abstract void test();
static class SubClass extends OverridableFromConstructor {
private int i = 10;
@Override
protected void test() {
System.out.println("You might think this will print 10, but it will print: " + i);
}
}
public static void main(String[] args) {
new SubClass();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment