This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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