0

I know that .equals compares the equality of an object in terms of its value while '==' checks the equality in terms of the reference and the value.

This code:

String s1="hi"; String s2=new String("hi"); Here both s1 and s2 have same hashcode, so even s1==s2 should return true but its giving false. I need a clear understanding on this.

Abhilash28
  • 645
  • 1
  • 9
  • 15

0 Answers0