3rd Mar 2019, 12:31 PM
Piotr Szkudlarek
Piotr Szkudlarek - avatar
10 Respuestas
+ 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.
3rd Mar 2019, 12:53 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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 ();
3rd Mar 2019, 1:36 PM
Denise Roßberg
Denise Roßberg - avatar
3rd Mar 2019, 1:09 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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.
3rd Mar 2019, 1:20 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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.
3rd Mar 2019, 1:27 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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
3rd Mar 2019, 1:48 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Ok, i found sollutiin. Instead of nextLine i used next() and it works, thanks with help on scanner
3rd Mar 2019, 1:24 PM
Piotr Szkudlarek
Piotr Szkudlarek - avatar
0
With another scanner i wanted user to input "Kobieta(women)/Mężczyzna(man)" to view the info od the subclass kobieta or mezczyzna
3rd Mar 2019, 1:03 PM
Piotr Szkudlarek
Piotr Szkudlarek - avatar
0
Ok, now it compiles, but still when i want to open one of the cases in switch it goes to default
3rd Mar 2019, 1:12 PM
Piotr Szkudlarek
Piotr Szkudlarek - avatar
0
Thanks, the thing is i didnt know what is this remove spaces u used and about scan.close
3rd Mar 2019, 1:39 PM
Piotr Szkudlarek
Piotr Szkudlarek - avatar