File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InputMismatchException

 
Jesse Crockett
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get an "InputMismatchException" from the following code



nextInt() is supposed to take that first '3' and pass it to 'quantity' but it isn't working. I don't really know what to ask. I'm hoping that someone will understand better what the exception means.
 
Joni Salonen
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the call to nextDouble, the pointer is at the end of the line, before the line break. So when you call nextLine() it returns the string that is between that place and the next line break -- an empty string! Next you try to get numbers from the scanner but it sees the word "first" which of course can't be parsed as an int.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic