Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can a constructor return 'null'?

807569Sep 26 2006 — edited Sep 27 2006
Consider the following code snippit.
MyClass myObj = new MyClass();
Is it safe to say that myObj IS NOT NULL?

Of course the constructor may have created a useless object, but the object reference itself (myObj) shouldn't be null. Correct?

Also, I realize that the constructor might throw an exception or something like that, but that's a different issue.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2006
Added on Sep 26 2006
11 comments
619 views