Which is better equals or == in Java?

equals() is a method of Object class. == should be used during reference comparison . == checks if both references points to same location or not. equals() method should be used for content comparison.

Sizin İçin Seçtik  How many types of objects are there in Java?

Leave a Reply

Your email address will not be published. Required fields are marked *