1.常量池(constant pool)
<span style="font-size:18px;color:#006600;">
</span>
public class linkString {
public static void main(String[] args) {
String s1 = "刘宁";
String s2 = "是逗比";
String s3 = "刘宁是逗比";
String s4 = s1+s2;
//编译时不能确定下来,无法直接引用常量池中的字符串
System.out.println(s3==s4);
String s5 = "刘宁"+"是逗比";
//编译时就确定下来,直接引用常量池中的字符串
System.out.println(s3==s5);
}
}