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 throwing exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "throwing exception" Watch "throwing exception" New topic

throwing exception

Nasir Munir

Joined: May 31, 2002
Posts: 22
I want to throw an exception from if block which is written in a try block. If there is an exception I want it to be handled in the catch block. If I use throw new Exception() in the "if" statement, will it go to the catch block defined as catch(Exception ex).
Can I get some help here ? thanks.

pseudo code:
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
The easiest way to find the answer is to try it. Write some code and see what happens. Experimentation is a great way to learn.

Nasir Munir

Joined: May 31, 2002
Posts: 22
thanks for a good suggestion
It worked !!!
I agree. Here's the link:
subject: throwing exception
It's not a secret anymore!