• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception Handling  RSS feed

 
Nihal Reddy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How will the compiler know an exception is thrown ?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nihal Reddy wrote:How will the compiler know an exception is thrown ?


For unchecked exceptions, it can't.

For checked exceptions, that information is in the class files. The compiler simply looks at what is executed in the try block, and use the class files to determine what checked exception may be thrown.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!