OK. Sounds good. I guess my IDE should be upgraded so it will can generate the better codes ...
-----Original Message----- From: Emmanuel Lécharny [mailto:[email protected]] Sent: Saturday, January 09, 2016 2:59 AM To: [email protected] Subject: eqlas() method Hi guys, I'm seeing a lot of equals() methods being implemented this way : public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } EncryptedData that = (EncryptedData) o; ... This is not the best practice. Here is what should be used instead : public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof EncryptedData) { return false; } EncryptedData that = (EncryptedData) o; ... The (!(o instanceof <yourClass>)) test will always return false if 'o' is not an instance of <yourClass> *and* when 'o' is null.
