it is because MyParentException is a superclass of MyChildException.
to avoid the exception, the correct hierarchy is this. furthermore, this
concept is important when you deal with java i/o.
try {
throw new MyChildException();
} catch (MyChildException e) {
System.err.println("Caught MyChildException");
} catch (MyParentException e) { // Compile error expected
System.err.println("Caught MyParentException");
}
On Fri, Mar 6, 2009 at 1:21 AM, miga <[email protected]> wrote:
>
>
>
> On Mar 5, 4:20 pm, Tanya Dina Ruttenberg <[email protected]>
> wrote:
> > Why do you get an "already been caught" exception when you place
> MyChildException before MyParentException? The exercise doesn't explain why
> you get this.try { throw new MyChildException();} catch
> (MyParentException e) { System.err.println("Caught
> MyParentException");} catch (MyChildException e) { // Compile error
> expected System.err.println("Caught MyChildtException");}
> > TDR
>
> See the pre-reading material, (study the graphics and comments):
>
>
> http://java.sun.com/docs/books/tutorial/essential/exceptions/definition.html
>
> and take into account that ChildException extends ParentException.
> >
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---