直接String出来的常量是储存在栈。
new 出来的对象是保存在堆里面。
String a = "hello";
String b = "hello";
String c = new String("hello");
System.out.println(b==a);//true
System.out.println(c==a);//false
常量相加是直接相加,变量相加会使用StringBuffer实现。
String a="hello";
String b="world;
String c=“helloworld";
String d="hello"+"world";
System.out.println(c==(b+c));//false
System.out.println(c==d); //true