This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes NoSuchElementException and error in line of code that does not exist ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoSuchElementException and error in line of code that does not exist ?" Watch "NoSuchElementException and error in line of code that does not exist ?" New topic
Author

NoSuchElementException and error in line of code that does not exist ?

justin smythhe
Ranch Hand

Joined: Jul 06, 2012
Posts: 107
I got the error below:

Exception in thread "main" java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:350)
.....extra stuff here.

I am curious to know why this error occurs. Why does it say line 350 ? None of my java files have more than 250 lines of code !
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
As the error message says, the error occurs in the Java source code for AbstractList:

java.util.AbstractList$Itr.next(AbstractList.java:350)

However, the whole stack trace is relevant and will point to the part of your code that caused the error in the Java source code. If you post the whole exception stack trace, we'll help you find the source of the error in your code.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
justin smythhe
Ranch Hand

Joined: Jul 06, 2012
Posts: 107
Greg Brannon wrote:As the error message says, the error occurs in the Java source code for AbstractList:

java.util.AbstractList$Itr.next(AbstractList.java:350)

However, the whole stack trace is relevant and will point to the part of your code that caused the error in the Java source code. If you post the whole exception stack trace, we'll help you find the source of the error in your code.


Can you suggest how I can see the stack trace myself and try to troubleshoot it ?
I hope that the analysis does not require me to be an "expert".
If I cannot do it on my own, then I will ask for help again.

Thanks.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
How are you running the program? If you have access to the console output, you should see the entire stack trace. The line you posted and that I quoted is but a single line in what should be many.

Tell us how you're compiling and running the program, and we should be able to point you to the console output to see the entire stack trace.

And, no, it doesn't require you to be an expert, but reading and understanding the exception's stack trace is a fundamental part of locating and correcting errors in code. Understanding how to use the stack trace is an important step in becoming a better programmer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoSuchElementException and error in line of code that does not exist ?