• Post Reply Bookmark Topic Watch Topic
  • New Topic

Understanding the Oracle Java Docs - Any explanations in simple language ?  RSS feed

 
Raghavendra Shockley
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any companion or guide book for the java API docs which explains things in simple words and in more detail ?
public class NoSuchElementException
extends RuntimeException

Thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration.


I am using the Scanner class whose nextInt() method throws the above exception. I could not understand what this error means in relation to the Scanner class.

NoSuchElementException

 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to scan when there are no input present for scanning. Use the hasNextInt() method prior to nextInt() and check if there are valid integer tokens present to be scanned.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you look at the Javadoc for the Scanner.nextInt method ? It explains there when the NoSuchElementException will be thrown.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raghavendra Shockley wrote:I am using the Scanner class whose nextInt() method throws the above exception. I could not understand what this error means in relation to the Scanner class.

In such a case, you're usually far better off looking at the docs for the method itself. There, it is pretty clear what the problem is.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!