my dog learned polymorphism
The moose likes Java in General and the fly likes out of scope expection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "out of scope expection" Watch "out of scope expection" New topic

out of scope expection

U Kvistborg

Joined: Oct 14, 2002
Posts: 29
I have one question, it actually came about when I saw some very baad code, but then I just had to see what happend so I made this example, but how can the exception ever be seen if it is out of scope for the catching class to see ?

My main class in one file and in one package.

My throwing class in another package but in one file I have both the thrower class and the runtime exception:

How can the main class actually see the out of scope exception ? I would have guessed that i'll had an out of scope sort of exception not that it actually prints the exception in the main and with the message text in this case just Hej.

[ Edited to use code tags - Paul Sturrock ]
[ January 17, 2007: Message edited by: Paul Sturrock ]

SCJP 1.4/1.5, SCWCD 1.4, SCBCD 1.3
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Not an advanced topic. Moving...

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: out of scope expection
It's not a secret anymore!