String 为null的一个问题
String str=null;
String str2="hello";
String str3=str+str2;
System.out.println(str3);
这个为什么输出的是nullhello,null不是表示空的吗,怎么还会转变成一个字符串了?
------解决方案--------------------String 存储 在内存中的表示去了解下,你就会明白了。
------解决方案--------------------这种疑问,多看看源码就知道了:
 System.out.print()
源码如下:
public void print(String s) {
	if (s == null) {
	    s = "null";
	}
	write(s);
}