View RSS Feed

Java String

Java String compare to determine Equality

Rate this Entry
by , 04-26-2012 at 07:59 PM (549 Views)
Comparison of the java string could be done in various ways, as given below. It is dependent upon javastringcompare type that which of them will be used.
* == Operator
* equals method
* compareTo method
Comparing, by using the “== Operator”
When String object references are compared, ==operator is used. If 2 variables of String are pointed towards similar object present in memory, then comparison will be returned true. In other case it will return false. It shall be noted that ==operator is not for comparison of the text content which is present in String objects. Just the two string references are compared by it. Given program will be printing “strings are not equal”, in first case. Otherwise, “strings are equal” in 2nd one.

Submit "Java String compare to determine Equality" to Facebook Submit "Java String compare to determine Equality" to Digg Submit "Java String compare to determine Equality" to del.icio.us Submit "Java String compare to determine Equality" to StumbleUpon Submit "Java String compare to determine Equality" to Google

Categories
Compare

Comments