字符串变量相加:先开空间(产生地址值),在相加,还需要判断当前相加后的结果在常量是否存在
*
* 字符串常来你相加:先相加,然后在常量池中是否存在该常量,如果存在,直接返回地址值;;如果不存在再开空间
public class StringDemo2 {
public static void main(String[] args) {
String s1="hello";
String s2="world";
String s3="helloworld";
System.out.println(s1+s2==s3);
System.out.println((s1+s2).equals(s3));
System.out.println("-------------------");
System.out.println(s3=="hello"+"world");
System.out.println(s1=="hello"+"world");
System.out.println(s3.equals("hello"+"world"));
}
}