• Post Reply Bookmark Topic Watch Topic
  • New Topic

Return statement at try block  RSS feed

 
Sur Chawla
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will happen if I have a return statement at the end of try block if
1)there is an exception?
2)there is no exception?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sur Chawla wrote:What will happen if I have a return statement at the end of try block if
1)there is an exception?
2)there is no exception?


Well, if there is an exception -- how will the return at the end of the try block be reachable?

Henry
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also.... since this topic is not related to threads, let's move this topic to the beginners java forum.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sur Chawla wrote:What will happen if I have a return statement at the end of try block if
1)there is an exception?
2)there is no exception?


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