Created
July 29, 2009 00:07
-
-
Save loganj/157768 to your computer and use it in GitHub Desktop.
This file contains 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
final public class DontDoThis { | |
static class SuperClass { | |
SuperClass() { | |
overridableMethod(); // this is a bad idea. wait, you'll see. | |
} | |
protected void overridableMethod() { | |
} | |
} | |
static class SubClass extends SuperClass { | |
final private Integer myVeryOwnField = 1; | |
@Override | |
protected void overridableMethod() { | |
myVeryOwnField.intValue(); // this is where you will get a NullPointerException | |
} | |
} | |
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