Hi all,
c the following code: ..............................//1
if("
String ".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
o/p : Not Equal
Now,c this code: ...............................//2
if( "String".endsWith(""))
Sytem.out.println("True");
else
System.out.println("False");
o/p : " True "
and , now this one: .............................//3
if( "String".startsWith(""))
Sytem.out.println("True");
else
System.out.println("False");
o/p The code produces : "True"
Now...my question is, if code 2 and 3 both produces "True" then how the output of the code 1 is "not Equal" !!
One can say ,it is because the code 1 is using String method and when a String method is used one new String is generated and return.
If u say this then explain me the following code :
if("String".concat("") == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
o/p : Equal

Hmmmm..I think my brain is not working properly...CAN SOME1 HELP ME ,,,
HELP !! HELP !! HELP !!
Regds.
<marquee> Ratul Banerjee </marquee>