
Signature
Cheers, Tilman
`Boy, life takes a long time to live...' -- Steven Wright
> [...]
> > default:
[quoted text clipped - 3 lines]
>
> Can you see the disparity between reality and your claim? ;-)
I can see the problem but it seems odd just to return an arbitrary integer
in the default case....
Patricia Shanahan - 27 Feb 2005 01:36 GMT
>>[...]
>>
[quoted text clipped - 9 lines]
> I can see the problem but it seems odd just to return an arbitrary integer
> in the default case....
So what should it do for that case? After you output the
message, what is your program supposed to do next? Maybe you
should consider throwing an exception, so that the caller
also knows what went wrong? Or calling System.exit, if it
is definitely fatal?
Patricia
Tilman Bohn - 27 Feb 2005 01:51 GMT
[...]
>> > default:
>> > System.out.println("No such input allowed");
[...]
> I can see the problem but it seems odd just to return an arbitrary integer
> in the default case....
There are two possibilites: Either the default case is to be regarded
as something more or less `normal'. Then you should return an appropri-
ate value. Or the default case is something exceptional that you cannot
handle. Then you should throw an appropriate Exception. There is no
third way for a method to exit, and certainly System.out.println() is
not such a third way.

Signature
Cheers, Tilman
`Boy, life takes a long time to live...' -- Steven Wright