Why is the result were not true? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 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 Antworten
+ 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