public class StringTest { public static void main(String[] args) { //判断是null还是空字符串 boolean b1 = Strings.isNullOrEmpty(null); //判断是null还是空字符串 boolean b2 = Strings.isNullOrEmpty(""); //null转换成空 String s1 = Strings.nullToEmpty(null); //null转换成空 String s2 = Strings.nullToEmpty(""); //空转换成null String s3 = Strings.emptyToNull(""); String s4 = Strings.emptyTonull(null); System.out.println(b1); System.out.println(b2); System.out.println(s1); System.out.println(s2); System.out.println(s3); } } //打印结果 true true null
null
注意:nullToEmpty 是转换成空格了