See what the following code snippet is:
A a = null try { a = new A(); } finally { a.foo(); // What happens at this point? }
Suppose the constructor throws an exception at runtime. On the marked line, am I always guaranteed to get a NullPointerException, or will foo () be called on the semi-constructed instance?
java instantiation exception
Lajos nagy
source share