4 Using MWArra y Classes
equals. This method indicates the MWArray obje ct is equal to the input
object. The
equals method of the MWArray classoverridestheequals method
of class
Object.
The prototype for the
equals m ethod is as follows:
public boolean equals(Object object)
Input Parameters
object
Array to compare this MWArray object to
Example — Comparing MWArrays with equals
Create a shared copy of the MWArray object and then compare it to the original
object. A return value of
true indicates that the two o bjects are equal:
Object S = A.sharedCopy();
if (A.equals(S))
System.out.println("Matrix S is equal to matrix A");
When run, the example displays this output:
Matrix S is equal to matrix A
hashCode. This method returns a hash code value for the MWArray object.
The
hashCode method of the MWArray class overrides the hashCode method
of class
Object.
The prototype for the
hashCode method is as follows:
public int hashCode()
Input Parameters
None
4-52
Komentarze do niniejszej Instrukcji