Originally posted by Joanne Neal:
Why don't you write a bit of code and see what happens.
Reading the
Java Language Spec, or a good book, would be better. While one cannot learn programming without doing some programming, it is all too easy to draw the wrong conclusions if one tries to learn purely by experiment.
In this particular question, I think it's reasonable to answer it.
Throwing in a catch block is perfectly reasonable. The original exception has been handled, by catching it. If something further goes wrong, throwing another exception is fine. This exception will not be caught in the same try..catch construct as the one you just caught; it will go to the nearest one outside.
Note that a catch block can catch an exception, do some stuff (which shouldn't throw), then re-throw the same exception. That is a common practice, actually. The re-thrown exception will not be caught in the same try..catch construct; it will go to the nearest one outside.
If a finally block is entered while an exception is being thrown, that original exception is lost, and replaced with the new exception. This is bad, so throwing in a finally block is most inadvisable. As well as not explicitly throwing an exception,
you should also take care over exceptions that might occur due to method calls within "finally".