| Author |
unreachable try{
|
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
compile error: unreachable statement try{
but why do i get this?
if there was not a throw statement just after the try block then isnt case 2 and case 3 unreachable statement as they are never reach as x is 1
|
 |
Linda Wiklund
Greenhorn
Joined: Oct 22, 2009
Posts: 11
|
|
|
on line 10 you throw an exception, hence, JVM will exit the method. the try-statement on line 11 will NEVER be reached.
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
i know that....but what is there to give an error in this?
|
 |
Linda Wiklund
Greenhorn
Joined: Oct 22, 2009
Posts: 11
|
|
|
Code that never will be reached, never used is redundant. It should not bee there. You'll get the same error if you have code after a return statement.
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
Thanks I will keep that in my mind as long as possible......
|
 |
 |
|
|
subject: unreachable try{
|
|
|