How do you stop scanner from overloading? (Java)
Murzikal (22)

In my Code, if you enter a large number like 10000000000000000000, it gives an error and ends the program.
Is there any way to fix this?
Error:

Exception in thread "main" java.util.InputMismatchException: For input string: "10000000000000000000"
    at java.util.Scanner.nextInt(Scanner.java:2123)
    at java.util.Scanner.nextInt(Scanner.java:2076)
    at Main.main(Main.java:17)
exit status 1
You are viewing a single comment. View All
malvoliothegood (174)

The number may be greater than the maximum number that Java can handle. Note the nextInt in the error message.

Murzikal (22)

@malvoliothegood Yeah, thanks. I forgot about the 32 bit max, 2,147,483,647.