#Problem with scanner and an if statement
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
because you are checking for object identity
if you want to check if the strings contain equal letters then you need to use .equals()
Im not sure i understand
playername is an independant variable, not from the object, it just gets put in it
playername contains a String Object. if you enter "Alejandro" then it is a String Object with the value "Alejandro" and then you are checking for object identity with == so if both Objects are stored at the same memory address and you are comparing to an other String Object, the String literal "Alejandro" you wrote in your source code and since these are two different Objects, they are stored at two different memory addresses so ==is false
for checking if both have the same value "Alejandro" you have to use .equals()
also, don't ignore warnings
write /close and let it autocomplete
thanks