| Author |
Runtime Exception@ Constructor
|
Mohammed Yousuff
Ranch Hand
Joined: Oct 17, 2007
Posts: 198
|
|
I have a class which has a main method. i getting some input value and parsing the value in constructor. However i like to know is that the best practices to throw a run time exception in a constructor. I did this because with out that value we can't process further. may i know your thoughts.
|
My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
The custom I know about is to print an error message from the main method ifYou aren't provided the correct number of command line arguments.One of the command line arguments is invalid.You can obviously elaborate what followsObviously you can use that sort of error message if you get an IllegalArgumentException back from your constructor. If the information is absolutely essential, then you don't want the program to execute at all. Is that of any help, or have I misunderstood the problem?
|
 |
 |
|
|
subject: Runtime Exception@ Constructor
|
|
|