Murat Kutluer wrote:Class A2 gives compile error beacuse last line is unreachable. Class A has an unreachle line too at the same position, but it compiles. Do you have any idea?
Murat Kutluer wrote:
I actually generated the code to post here. I know the difference but I dont know why it does like that. Both have a statement after try-catch block. The difference is that in class A2 last catch block has a throw new exception statement.
Murat Kutluer wrote:I tried lots of variation and come to a conclusion that if the all catch blocks that coming after the working catch block (in this case NullPointerException) throw an exception, this causes to compile error. If one them do not throw an exception, it works. This seems reasonable.
Murat Kutluer wrote:This one compiles too. This is actually a bit weird. This one and the first sample class A both have a unreachable statement after try-catch block, but compiler ignores or can not get the situation.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |