I fail to understand the outputs below:
System.out.println(s1.equals(s2)+"a");  ->truea
System.out.println(s1==s2+"a");         ->false
Where s1 & s2 are declared as same String "abc" i.e String s1="abc"; String s2="abc";
I fail to understand the outputs below:
System.out.println(s1.equals(s2)+"a");  ->truea
System.out.println(s1==s2+"a");         ->false
Where s1 & s2 are declared as same String "abc" i.e String s1="abc"; String s2="abc";
 
    
     
    
    According to the Oracle documentation the + operator has higher precedence than equality check.
 
    
     
    
    Because s1 is one string object while s2 is another string object. They have different memory addresses.
