• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

could please answer this Q

 
zaghal mohd
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is any conditions to use try{} catch{}
or throws and what is the differnt betwen them
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused. Your question is very vague. Is there something, in particular, that you're confused about concerning exception handling? Perhaps, if you provide some more details, we can help more. For now, all I can do is point you to some articles concerning exception handling.
Exceptions in Java
Designing with Exceptions
I hope that helps a little,
Corey
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are calling a method that throws a checked exception, the calling method must either deal with the checked exception with a try-catch block or rethrow it by explicitly declaring it in its throws clause.
 
zaghal mohd
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I mean it concerning exception we have to way that we can throw exceptions one must deal with (try catch block) and other using (throw) clause there is any conditions that give me choice to chose any one or it open door to use any one
 
Snigdha Solanki
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your program throws a checked exception then either you have to use try/catch block or you can use throws keyword in the method defintion.
I guess you can use throws in cases where you just want to ignore the exception. In the other approach you can catch the exception and take any relevant action.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic