本帖最后由 2528870651 于 2014-4-4 18:45 编辑
- class Test2
- {
- public static void main(String[] args)
- {
- String str1 = "Hello";
- String str2 = "World";
- String str3 = "HelloWorld";
- System.out.println(str3 == str1+ str2); //false
- System.out.println(str3 == str1 + "World"); //false
- System.out.println(str3 == "Hello"+"World"); //true
- System.out.println(str1 + "World" =="Hello"+"World");//false
- //不都是HelloWorld吗???为什么结果会不同呢
- }
- }
复制代码 |