Hi Raj,
As you're dealing with Strings
you should use the .equals(String s) method that the String class overrides from Object. This evaluates the String value.
Using == on the Strings returned returns false because they are different String objects, even though their hashCode() may be the same.
Check out this code:
[CODE]
String s1 = "Hello";
String s2 = "Hello";
String s3 = new String("Hello");
System.out.println( s1.hashCode() );
System.out.println( s2.hashCode() );
System.out.println( s3.hashCode() );
System.out.println( s1==s2 ); // s1 and s2 refer to the same object in the String pool
System.out.println( s1==s3 ); // s1 and s3 refer to different objects, new String created
System.out.println( s1.equals(s2) ); // compares value
System.out.println( s1.equals(s3) ); // compares value
[/ CODE]
Cheers,
Kem