Throw an exceptionConstructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception
Java
Topic: Constructors
How should a contructor handle a failure?
Browse random answers:
What is the difference between a constructor and a method?
Why constructor does not have return type in java?
Where and how can you use a private constructor?
What are Characteristics of constructor:?
What is Parameterized constructor?
What is copy constructor?
What is Default constructor ?
What is Dynamic constructor ?
How should a contructor handle a failure?
What is virtual constructors/destructors?