budsy remo wrote:i saw the thread but the problem is that it is returning false and not true .
String s = new String("ranch");
String s1 = new String("ranch") ;
or something like
it should return true but it returns false
In the first case, you explicitly created two new strings. The JVM will honor that request, so you get two objects.
In the second case, you explicitly created a new string (actually one that you created earlier). The JVM will honor that request, so it should be different than the one created earlier for the string literals.