Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

throwing exception

 
Nasir Munir
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for a good suggestion
It worked !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic