0
Another time, whats wrong?
10 Antworten
+ 6
On sololearn you can only one scanner.
Scanner scan = new Scanner(System.in);
kod = scan.nextInt ();
... = scan.nextLine ();
What do you mean with "another time"? It is not easy to read your code because of your polish (hope I'm right) variable names.
+ 6
Piotr Szkudlarek Normally your ide will cut the connection of your scanner from the device if you end the program. But it is better to close the scanner at the end of your program:
scan.close ();
+ 5
If you write plecc = "Kobieta" it works. So it has to do with scan.nextLine ();
I need to think about it. Maybe there is a whitespace at the end of your string.
+ 5
You can also remove all spaces. I changed it in my code:
https://code.sololearn.com/c0OefZPnTUgu/?ref=app
ps: Your solution to use next () is more elegant. ;)
pps: The white space was at the beginning of the string. But I don't know why.
+ 4
It does not matter if you didn't know this. Thats why we are here: To learn it.
Here you find a list of the Scanner methods with explanations:
https://www.tutorialspoint.com/java/util/java_util_scanner.htm
+ 1
Ok, i found sollutiin. Instead of nextLine i used next() and it works, thanks with help on scanner
0
With another scanner i wanted user to input "Kobieta(women)/Mężczyzna(man)" to view the info od the subclass kobieta or mezczyzna
0
Ok, now it compiles, but still when i want to open one of the cases in switch it goes to default
0
Thanks, the thing is i didnt know what is this remove spaces u used and about scan.close