+ 1

Someone to help me? I try to run my code but it doesn't and I don't see where is the bugg..

Go to my profile and see the code "We The Human"

7th Jul 2017, 5:28 AM
Issa Samake
Issa Samake - avatar
1 Réponse
+ 6
Comparing strings with == can get unexpected results when taking input. Keep in mind what == actually does (compares reference for Objects). Two ways to fix this: You can use .equals("w") instead of ==. Example/ if(choice.equals("w")) { } Or You can take the input as a char, then compare it with the character 'w'. (Same things for 'm'). Example/ char choice = sc.next().charAt(0); if(choice == 'w') { }
7th Jul 2017, 6:03 AM
Rrestoring faith
Rrestoring faith - avatar