爲什麼第一比較(S1 == S2)顯示相等,而第二比較(S1 == S3)顯示不等於....?
public class StringComparison
{
public static void main(String [] args)
{
String s1 = "Arsalan";
String s2 = "Arsalan";
String s3 = new String ("Arsalan");
if (s1 == s2)
System.out.println (" S1 and S2 Both are equal...");
else
System.out.println ("S1 and S2 not equal");
if (s1 == s3)
System.out.println (" S1 and S3 Both are equal...");
else
System.out.println (" S1 and S3 are not equal");
}
}
謝謝......現在,在閱讀String Pooling之後,我很清楚......! – Arsalan