<<< The equals( ) method | Index | Abstract Classes >>> |
To override the equals() method of the Object class, add your own equals() method to the class.
For example, the Product class could implement the method as follows:
@Override public boolean equals( Object object ) { if ( object instanceof Product ) { Product product2 = (Product) object; if ( code.equals( product2.getCode() ) && description.equals( product2.getDescription() ) && price == product2.getPrice() ) { return true; } } return false; }//equals
<<< The equals( ) method | Index | Abstract Classes >>> |