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 does equals method work with objects in Java?

Leave a Reply

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