This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in Exception  RSS feed

 
Irfan Zubair
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I don't know why I am getting this error.

MyClass.java:6: unreachable statement
System.out.println("2");
^
1 error

Can anyone tell me why?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12529
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first, let's format this correctly:


Now...how exactly do you think you can reach line 9? As soon as you throw the exception on line 8, you jump to the finally block on line 11. So there is no possible way for this line to execute. The compiler can tell, and assumes that you made a mistake somewhere.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!