File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes return in catch block! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "return in catch block!" Watch "return in catch block!" New topic

return in catch block!

Nick Petas
Ranch Hand

Joined: Jan 31, 2007
Posts: 40
What does a single return in a catch block do?
Thank you.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Nothing less or more then a regular return statement. Why don't you try it?

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Nick Petas
Ranch Hand

Joined: Jan 31, 2007
Posts: 40
Where exactly does it return?In the try block?
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4617

The same place it returns to outside the try block. Ask yourself, where does return normally return to?

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link:
subject: return in catch block!
It's not a secret anymore!