Reputation: 7
Why does Java accept 1234567891 as input but not 987654321 ? I keep getting NoSuchElementException, and I am just wondering why the error.
Upvotes: 0
Views: 67
Reputation: 1518
Range of 4 byte integer in Java is
–2,147,483,648
to 2,147,483,647
Thus it won't be able to accept 987654321
in scanner.getInt();
To accept the above mentioned value , use scanner.getLong()
Upvotes: 2