I have two strings,String one = new String("word");
String two = new String("word");
Why doesSystem.out.println(one.equals(two));
Return true given that one and two are two different String
objects.
Pyler
0
Junior Poster in Training
Recommended Answers
Jump to Postmind that the == comparison in this specific case can't be relied upon to return false.
The runtime (and even the compiler in this simplified scenario) might determine to optimise things in such a way that both point to the same String as stored on the String constant pool in …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.