package com.fgy.demo;
public class demo06 {
public static void main(String[] args) {
String str1 = "aaa ";
String str2 = null;
String str3 = " bbb";
System.out.println(str1 + str2 + str3); // aaa null bbb
}
}
// String源码
public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString();
}
Java字符串之间拼接时,如果有null值,则会直接拼接上null
点赞
收藏