Why does it turn every time to the "else" clause? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Why does it turn every time to the "else" clause?

Maybe the if statement is false but i'm not sure pls help The output us everytime "nope! try again" even if the answers are correct Answers: 24 berlin java https://code.sololearn.com/c8qU92phJIvs/?ref=app

1st May 2018, 3:20 PM
furkman
3 Antworten
+ 2
Here. A couple of things: To compare Strings use .equals(). string1.equals(string2) Now, to get the word you are better off using .next() instead of nextLine() https://code.sololearn.com/cdZKJ34HTEmd/?ref=app
1st May 2018, 3:31 PM
cyk
cyk - avatar
+ 2
ahhh thank you very much! I havd been desperate for hours ­čśé­čśé
1st May 2018, 3:40 PM
furkman
+ 1
For checking string equality, you use .equals or .equalsIgnoreCase.. Like String s ="a" , s1 = "A"; if(s.equals(s1)) // false If you want to ignore the case you do. if(s.equalsIgnoreCase(s1)) // true Replace the == with .equals or .equalsIgnoreCase in case of Strings
1st May 2018, 3:25 PM
Aaron Stone
Aaron Stone - avatar