Re: Exception handling




> Sharp Tool wrote:
> > Hi,
> >
> > I want to check if a statement throws an exception.
> > If it does, I want to deal with it then and there, and not at the catch
> > claus.
> > See code below:
> >
> > ...
> > String[] str = {"dinner"};
> > if (str[1].charAt(0) throws ArrayIndexOutOfBoundsException) // compile
error
> > {
> > //do something 1
> > }
> > else //do something 2
> >
> > Is this possible?
> >
> > Sharp Tool
> >
>
> Why not:
>
> try {
> // whatever
> // do something 2
> } catch (ArrayIndexOutOfBoundsException e) {
> // deal with it, ie do something 1
> }

Like i said I don't want to deal with the exception in the catch claus.
Doing so, will not return me to where I left off.

Sharp Tool



.



Relevant Pages

  • Re: Exception handling
    ... >> I want to check if a statement throws an exception. ... >> Sharp Tool ... > if an exception is likely to be thrown. ... check if an exception would be thrown directly and explicity. ...
    (comp.lang.java.programmer)
  • Re: Exception handling
    ... Sharp Tool wrote: ... I want to check if a statement throws an exception. ... if throws ArrayIndexOutOfBoundsException) // compile error ... if an exception is likely to be thrown. ...
    (comp.lang.java.programmer)
  • Re: Exception handling
    ... Sharp Tool wrote: ... I want to check if a statement throws an exception. ... if throws ArrayIndexOutOfBoundsException) // compile error ...
    (comp.lang.java.programmer)
  • Exception handling
    ... I want to check if a statement throws an exception. ... claus. ... Sharp Tool ... Prev by Date: ...
    (comp.lang.java.programmer)
  • Solve this beauty
    ... String firstPart = null; ... Sharp Tool ... Prev by Date: ...
    (comp.lang.java.programmer)