Java question: need answer soon

Are there any side effects of creating but not throwing an exception in Java? I need to examine the stack trace, but I didn’t know of any other way to do it.

Thanks for your help,

No, there are no side effects. You can:

Throwable thr = new Throwable();

all you want, and nothing will happen (other than that the stack trace of that point in the code gets printed). An instantiated Throwable (or Exception, or any other subclass) is just an object, with methods that you can call. Something only happens if you throw it.

There are no side effects. In fact there aren’t any effects at all. Why would you do this?

I think he’d do it as an easy way to get the stack trace, e.g. for debugging. As he mentioned. I happen to think it’s a good idea.