java - Why System.out.println("hey s1==s2:"+s1==s2); prints "false" as the output instead of printing "hey s1==s2:false" -
Output: Why line # 5 results as "O s1 == s2: false" instead of just "false" as output?
false false s1.equals (s2): true s3.equals (s4): true wrong s1.equals (s3): true Hey s1 == s2: true
line 5: System.out.println ("he s1 == s2:" + S1 == s2);
Before resolving operator's priority "s1 = s2:" + s1
before and then s2 For those who go false.
Give it the highest priority to solve it right. Parenthesis is the top priority.
System.out.println ("he s1 == s2:" + (s1 == s2));
Comments
Post a Comment