wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions Handling in Constructors" Watch "Exceptions Handling in Constructors" New topic

Exceptions Handling in Constructors

Kaushik Subramanya

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

Joined: Sep 23, 2000
Posts: 3255
It's exactly same as the way you throw/catch exceptions in any method.
Get Certified, Guaranteed!
(Now Revised for the new Pattern)

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

Joined: Mar 22, 2000
Posts: 12761
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.

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