aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exceptions Handling in Constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions Handling in Constructors" Watch "Exceptions Handling in Constructors" New topic
Author

Exceptions Handling in Constructors

Kaushik Subramanya
Greenhorn

Joined: Sep 26, 2000
Posts: 9
All,
Can anyone tell me how do I catch and handle exceptions within my constructor.
~Kaushik
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3205
    
    2
It's exactly same as the way you throw/catch exceptions in any method.
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
However, unless the exception is something that you can recover from and still produce a valid object, it is better to let the constructor throw the exception and handle the problem somewhere else.
Bill

------------------
author of:


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions Handling in Constructors
 
Similar Threads
writing from a jar
executeBatch() not executing
while loop
Questions from mock Exam !!!
my query is successfully running in database but it is returning empty resultset in my java program