+ 1

Why is the result were not true?

I'm trying to test if the input username of the user match with the username in User class. https://code.sololearn.com/cvQB819ecied/?ref=app

17th Nov 2022, 4:11 AM
Mozzie
Mozzie - avatar
2 Respostas
+ 3
Use the equals method instead of == because you want to compare the values. As is, it will always evaluate to false because it's checking if user1 and username1 are pointing to the same memory address. if(user1.equals(username1))
17th Nov 2022, 5:17 AM
Caroline Russell
Caroline Russell - avatar
+ 2
Thank you
17th Nov 2022, 5:29 AM
Mozzie
Mozzie - avatar