Hi,
The string objects behaving differently in differnt situations. Plase find the following code giving differnt result.
if("String".replace('t','t') == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
/*************************************/
if("String".replace('g','G') == "String".replace('g','G'))
System.out.println("Equal");
else
System.out.println("Not Equal");
/*************************************/
if(" String ".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
Please let me know why I am getting different results in the above three sinarios.
Thanks & Regards
Rajesh
The string objects behaving differently in differnt situations. Plase find the following code giving differnt result.
if("String".replace('t','t') == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
/*************************************/
if("String".replace('g','G') == "String".replace('g','G'))
System.out.println("Equal");
else
System.out.println("Not Equal");
/*************************************/
if(" String ".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
Please let me know why I am getting different results in the above three sinarios.
Thanks & Regards
Rajesh