<<< Access to object's type | Index | The equals( ) method override >>> |
How the equals method of the Object class works:
(a) Both variables refer to the same object:
Product product1 = new Product(); Product product2 = product1; if ( product1.equals( product2 ) ) // true
(b) Both variables refer to different objects that store the same data:
Product product1 = new Product(); Product product2 = new Product(); if ( product1.equals( product2 ) ) //false
<<< Access to object's type | Index | The equals( ) method override >>> |