Why String comparison with '==' is illegal,eventhough it works fine.Kindly explain?
ramjeev -2 Junior Poster in Training
Recommended Answers
Jump to Post— javaAddict 900If you run this code you will see that '==' doesn't work:
public static void main(String [] args) { String s1 = new String("aa"); String s2 = new String("aa"); System.out.println(s1==s2); // false System.out.println(s1.equals(s2)); // true }The '==' checks if they are the same object and the …
All 4 Replies
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
ramjeev -2 Junior Poster in Training
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
ramjeev -2 Junior Poster in Training
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.