I need to compare 2 instances of a class, that has equals method overridden – it returns string that equal concatenation of parameters. But I need be sure that exists only 1 instance. For this I think to check references.
Is it possible in java?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
==to compare the references. It’s enough to make sure if different variables refer to the same instance.