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 Respostas
+ 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