0
Why "==" working differently for strings in java
let's take strings as a ="a" b="b" c=a+b // so it will be "ab" d = "ab" Then why a & d are not equal as per the following code https://code.sololearn.com/cIU375SG6BhG/?ref=app
1 Antwort
0
== compare references for strings and objects.. Not the conntents.
Use equals() method for comparing content.
c, d reference are different so returns false.
Try :
d = c; now both will have same reference so returns true..
Hope it helps..