0
Java programming trace the output?
What is the output of this code? String a=âaâ; String b=âbâ; String c=a+b; String d=âabâ; If(c==d) System.out.println(1); else System.out.println(0); Output is 0 why? Please solve my doubt!! because I lost this question in SoloLearn challenge.
2 Answers
+ 2
'==' is a reference comparison.
c and d has same value but different reference. So
c.equals(d) will return true
c==d will return false
0
b