0

Any explanation for why not share the same reference at string pool?

https://code.sololearn.com/cwRfX1nUKs8U/?ref=app

8th Aug 2020, 4:54 PM
Reham Aboelyazied
Reham Aboelyazied - avatar
7 Antworten
+ 5
The correct "operator" to compare the VALUES of two strings is the equals-method. You're comparing two different objects, which just contain two equal string values. This doesn't make them to the SAME objects.
8th Aug 2020, 4:59 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
@sandra I know "equals" and when to use but I can't understand why c and d do not refer to the same object as I thought that d is at string pool because there is no "new String()" but is that mean c is not allocated at the string pool by concatenation
8th Aug 2020, 5:49 PM
Reham Aboelyazied
Reham Aboelyazied - avatar
0
@Coder that's a good tip 💡 thanks a lot
8th Aug 2020, 8:18 PM
Reham Aboelyazied
Reham Aboelyazied - avatar