in #1 substring create new String and return ,and compare with "String" so it is giving Equal in #2 replace create new String "StrinG" and compare with "StrinG" then it should also give Equal but it is giving NotEqual
please explain me .in doc also they said that both are construct new string...
posted 10 years ago
if("String".substring(0) == "String")
Condition returns true because in substring method, when 0 is passed as argument it returns the same string(because result of substring method is going to be same as main string("String"))