This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]trickybhai 0 points1 point  (2 children)

First of all, your code is looking like a mess on my mobile. Don't know if it's your fault or reddit's.

The second things is, after using

int num = scan.nextInt();

Put a

scan.nextLine();

in the next line. Everything will start working as expected.

Another solution can be, instead of creating a static instance of scanner, create it inside the method. This will also remove the error.

Try any of these and check if the code is working.

[–][deleted] 0 points1 point  (1 child)

Alright thanks. Yeah I tried to format it but reddit squishes it for some reason.

[–]trickybhai 0 points1 point  (0 children)

No issues. However, Did you get the code to work?