本帖最后由 a397131103 于 2015-5-24 21:55 编辑
String s1 = "hello";
String s2 = "world";
String s3 = s1 + s2;
String s4 = "helloworld";
System.out.println(s3); //helloworld
System.out.println(s4); //helloworld
System.out.println(s4 == (s1+s2)); //false
System.out.println(s4 == ("hello"+"world")); //true
上面两个结果怎么区别,总是搞不清楚,请大家帮忙解释下.
System.out.println(s4.equals(s1+s2)); //true
|
|