Of course you could start by checking for args.length == 0 and outputing an "error" message straight away.
B.T.W Welcome to the wonderful world of error/exception handling.
She could also check if args.length == 0 and if so, ask the user if he would like to input a set of numbers now, then ask for how many, and ask for each number one at a time to be inputted...
-blazed <-- like to avoid error/exception handling, even though it's impossible
She could also check if args.length == 0 and if so, ask the user if he would like to input a set of numbers now, then ask for how many, and ask for each number one at a time to be inputted...
-blazed <-- like to avoid error/exception handling, even though it's impossible
Sure, if I were the user then I'd confirm and then state that I would like to enter
-42 numbers; then just wait ... ;-)
Sure, if I were the user then I'd confirm and then state that I would like to enter
-42 numbers; then just wait ... ;-)
kind regards,
Jos
Like I said, it's impossible to avoid, but realizing this, simply add a if input is negative with a while loop that simply asks again for an input till it's positive (still trying to avoid spitting out the error, even though it's the same thing)...
Now you're talking. And what does it do if the input doesn't match?
Throw an error/exception, prints the stack automatically.. . are you still agreeing with me that despite my hatred for them it's impossible to avoid error/exception handling? I know, I know...
Comment