Skip to content

Instantly share code, notes, and snippets.

@aeris
Created May 22, 2013 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aeris/5626802 to your computer and use it in GitHub Desktop.
Save aeris/5626802 to your computer and use it in GitHub Desktop.
Java silly code…
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)
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