
Determine If an Error Has Occurred During Object Construction
This can be achieved in Java by throwing an exception from your constructor. Since constructors cannot return a value, this is the only way to perform error handling. Class MyCLass{ private int x; File file; MyClass() throws MyException{ x = 10; try{ file = new File(“c:\myFile.txt”); } catch(Exception e) {