Created
January 1, 2018 11:07
-
-
Save jnizet/bbea3b4072329cd7540d8c2a32fc7244 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
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