|
|
Re: Simple array equality question (hopefully!)
|
Posted: Oct 8, 2004 5:17 PM
|
|
|
An array in Java is an object. Here, str and str2 are two different objects. By default, equals() method compares the references to two objects. It returns true only if two objects being compared are same. That is, o1.equals(o2) is same as o1 == o2 unless the class of o1 overrides the equals() method. Since array object's class is built-in class types, we cannot override array class equals() method. So, you will have to accept the default behaviour. That is, str.euals(str2) is same as saying str == str2. And, you know that str is certainly not same as str2.
|
|