Created
May 22, 2013 11:08
-
-
Save aeris/5626802 to your computer and use it in GitHub Desktop.
Java silly code…
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 class NpeWithoutMethodCall { | |
public static void main(String[] args) { | |
Integer defaultValue = null; | |
Integer value = true ? defaultValue : 0; | |
} | |
} | |
// javac NpeWithoutMethodCall.java && NpeWithoutMethodCall Foo | |
// Exception in thread "main" java.lang.NullPointerException | |
// at NpeWithoutMethodCall.main(NpeWithoutMethodCall.java:4) |
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 class TrueIsFalse { | |
public static void main(String[] args) { | |
if ( true ) { | |
// \u000a\u007d\u0065\u006c\u0073\u0065\u007b | |
System.out.println("true"); | |
} | |
// \u000a\u0069\u0066\u0028\u0066a\u006cs\u0065\u0029\u007b\u007d | |
else { | |
System.out.println("false"); | |
} | |
} | |
} | |
// javac TrueIsFalse.java && java TrueIsFalse | |
// false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment