[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: why goto ?



On Thu, Mar 15, 2001 at 10:43:09AM -0800, Rajeev Joseph typed:
> Only abusive Java code would ever use the
> try-catch-finally clauses as a control structure. Well
> behaving java code uses those statements only as a
> mechanism for error handling.

Beg to differ. Would you say the following use of a try catch block is
*abusive* ? 

  int number;

  try
  {
    number= Integer.parseInt(someString);
  } catch (NumberFormatException e)
  {
    number=someDefaultNumber;
  }     

I'd say it is pretty well behaved Java code equivalent to the pseudo
code 

if (someString is a valid number formatted as string)
     number = parsed Value of the string
else          
     number = default value

     
Kala