Hi,
public class
Test {
public static void main (
String args [ ] ) {
if("String".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}
The output of this code is Equal but when I change the code to
public class Test {
public static void main ( String args [ ] ) {
if(" String ".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}
Why is this code giving an output of Not Equal . ( In the second code I'm giving spaces in the " String " ) .
Thanks.