loading...

re: Why does this Java code keep throwing Exception in thread "main" at line 8 when line 8 is the declaration for the main method? VIEW POST

FULL DISCUSSION
 

Java can give warnings like that if it knows that that method is a problem, but doesn't know where in the method the issue is coming from.

A tried and true way of debugging something like this is to simply comment out the entire method body. Then, uncomment one line at a time and try to recompile after uncommenting the line. The method will again throw the error when it reaches the offending statement.

 

Thanks, that helped alot!
But, when I commented out the entire method it still threw that same error....

 

Okay, this tells me that it is that line. The compiler most likely requires anything that can throw an Exception to try and catch it. Could be your issue.

code of conduct - report abuse