+ 1
How are these 2 strings different ..?
a substring containing all elements of the original string is created but these are not equal., how...? https://code.sololearn.com/c9snOqooORdn/?ref=app
1 Odpowiedź
+ 1
because == checks if the variables references the same object, not wether their data are equal. lets say string x = "hello" and string t = "hello". == will return false because the two strings are different instances on the memory and the variables reference two different addresses. but if you set string t = x then == will return true. think of variables as names and object as a person. if a person has nicknames, doesn't matter what nicknames are, they all refer to the same person. if like say a person has an identical twins, and you use their names to compare the two, each name refers to different person even if they look identical