compare String objects using s1.equals(s2) and not (s1==s2). Note that == comparison operator is for primitive data types. So you code should read:
System.out.println((s1.equals(s2)); hope it works. On Jul 20, 3:32 pm, Rohit Bansal <[email protected]> wrote: > Let I had following code snippet, > String s1="Hello"; > String s2=s1; > System.out.println((s1==s2)+" "+ s1==s2); > > OUTPUT: false > > Query: I need understanding of output...its strange for sure but true; --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
