GeeCON Prague 2014*
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
Author

throwing exception

Nasir Munir
Greenhorn

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
Rancher

Joined: Aug 05, 2005
Posts: 3602
    
  15
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.


Joanne
Nasir Munir
Greenhorn

Joined: May 31, 2002
Posts: 22
thanks for a good suggestion
It worked !!!
 
GeeCON Prague 2014
 
subject: throwing exception