本帖最后由 qlmmys 于 2019-10-18 15:02 编辑
第一题:
private static String a = "ab";
public static void main(String[] args){
String s1 = "a";
String s2 = "b";
String s = s1 + s2;
System.out.println(s == a);
System.out.println(s.intern() == a);
}
第二题:
String a = "ab";
final String bb = getBB();
String b = "a" + bb;
System.out.println((a == b));
private static String getBB() {
return "b";
}
第三题:
String a = "ab";
final String bb = "b";
String b = "a" + bb;
System.out.println((a == b));
|
|