0
== operator in jsp and Java
since jsp is basically Java only why shouldn't the '==' operator can't be used to compare between two Strings? enter code here if String name="SonGoku"; String name2="SonGoku"; in '**java**' **(name==name2)** is **true** in 'jsp' (name==name2) is not true why this difference is there ? should we always use ".equals()" in jsp ?
2 odpowiedzi
+ 2
I think .equals() is also the way to go for String comparison in Java, == only returns true if both name & name2 points to an identical object.
Hth, cmiiw
+ 1
For string comparison, Java recommend you to use the == operator instead of the equals() method