+ 2

Why this code doesn't work?

Please help me. It is very important. import java.util.Scanner; import java.util.Random; import static java.lang.System.out; public class WennDasKlapptIchSchwoer { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); String beschreibung = keyboard.next(); switch (beschreibung) { case "Sehr gut": out.println('A'); break; } } }

7th Apr 2017, 4:06 PM
nwytg
4 Answers
+ 17
Use keyboard.nextLine(); /* this method takes input including space, but next() doesn't next() is only taking Sehr */
7th Apr 2017, 4:08 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 10
Its System.out.println();
7th Apr 2017, 4:08 PM
Dev
Dev - avatar
+ 2
@Shamima Yasmin thank you very much šŸ’–. Puh I worked on a long code about 2 hours. and I didn't finde the false thing, because there wasn't a compile error
7th Apr 2017, 7:23 PM
nwytg
+ 1
@Dayvne I have imported the static java.lang.System.out class, so I dont need to write every time when I need to print something out write SYSTEM. out.println (); But thank you for your try to help me.
7th Apr 2017, 8:27 PM
nwytg