Skip to content

Instantly share code, notes, and snippets.

@upangka
Created December 24, 2019 00:55
Show Gist options
  • Save upangka/fff517f48e41cc17e49346cb3f404686 to your computer and use it in GitHub Desktop.
Save upangka/fff517f48e41cc17e49346cb3f404686 to your computer and use it in GitHub Desktop.
null错误
package org.caucoder.nullex;
public class NullString {
public static void main(String[] args) {
String str = null;
System.out.println(str);
System.out.println(str==null);
// -----------------------------
System.out.println(String.valueOf(str));
System.out.println(String.valueOf(str)==null);
}
}
/**
null
true
null
false
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment