Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite0
i cant match string characters and get the desired output. If user types Yes then also if statement gets skipped to else. Why?
1 Réponse
+ 9
Strings are objects, and an object can only be equal to itself. So the nextLine() String and the String in the condition are different objects.
String inputs must be compared like this:
if (a.equals("Yes"))