【发布时间】:2014-02-19 22:23:11
【问题描述】:
当我执行以下代码时,输出为“nullHelloWorld”。 Java是如何对待null的?
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
String str=null;
str+="Hello World";
System.out.println(str);
}
}
【问题讨论】:
-
+1: 滥用字符串连接规则 :) 我不知道。
标签: java string null string-concatenation