• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

try in exception  RSS feed

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks

Please help me to know in which condition try block will not be executed in exception handling

Example:-
try{
\\ block will not be executed in which conditions
}
catch{
\\ some code here
}
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gaurav,

Your question is obscure but here what you could ask:

In what cases catching certain exception is not ok, until the try block throws it? OK? If this is your question here you go:

1- If the you catch any subclass of Exception class, except subclasses of RuntimeException, you must throw that exception in the try block.
2- Even if you declare that exception in the method, but you catch it too, your code must throw that exception in the try block, otherwise code wont compiler.
3- RuntimeException (itself and its subclasses), you can throw it without putting try catch block or without declaring it in the method.


Regards,
cmbhatt
 
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put try block in if condition and that if condition if returns false then try block will not excute.
 
Gaurav Pavan Kumar Jain
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Raj
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!