Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you have a try/catch inside a try

 
Robert Johnson
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you have a try and catch inside a try block

???
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
answer is yes.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or inside a catch block or a finally block. You can do pretty much anything inside one set of curly braces that you could do inside any other set of curly braces.

Too much nesting gets messy and hard to read, so it's probably a hint that you should pull the nested bits out to their own methods.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too much nesting gets messy and hard to read, so it's probably a hint that you should pull the nested bits out to their own methods.


EXACTLY. Sorry to yell that.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic