Results 1 to 4 of 4
Thread: InputMismatchException
- 09-22-2012, 08:20 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 2
- Rep Power
- 0
InputMismatchException
Working my way thru a basic java programing book I came across a strange problem . Trying to get keyboard input through scanner I get a InputMismatchException when I enter 2dot5 ( 2.5 ) but it takes it as a double when I enter 2comma5 (2,5). Anybody know what could be happening?
-
Re: InputMismatchException
This sounds like an issue with the locale used by your Scanner object. Consider changing this by calling .useLocale(...) on your Scanner object, using a locale that is more in line with your desired numeric format.
i.e.,
Java Code:Scanner myScanner = new Scanner(System.in); myScanner.useLocale(Locale.US); // for United States-compatible number formatting
- 09-22-2012, 09:41 PM #3
Member
- Join Date
- Sep 2012
- Posts
- 2
- Rep Power
- 0
Re: InputMismatchException
Thank you that did it. I am a gringo living in Peru.
-
Re: InputMismatchException
Similar Threads
-
Having trouble getting scanner to read double from .txt file InputMismatchException
By weighyoursins in forum New To JavaReplies: 1Last Post: 09-20-2012, 09:54 AM -
InputMismatchException
By jihad in forum New To JavaReplies: 5Last Post: 12-17-2011, 03:10 PM -
How to Extend an Exception in Java (InputMismatchException) ?
By Hatem in forum Advanced JavaReplies: 2Last Post: 02-11-2011, 09:03 AM -
try-catch InputMismatchException in a while loop
By themulator in forum New To JavaReplies: 17Last Post: 10-12-2010, 04:49 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks