"code not reachable" - This error comes when the code what you have written may not be executed at all.
For Example: while writing catch blocks, in the parameter field child exception elements should come first before their parents. That is
This gives you an unreachable code exception because the Exception catch block can catch even NumberFormatExceptions also.
The reason why Exception catch block can catch NumberFormat Exceptions: We know that NumberFormatException is a child of Exception class. So the parent refernce can be used for child objects also right.
The above code is one way where you can get the Unreachable code error. Hope you can find others on your own, if the above concept is explained
Hello harish, I use Eclipse 3.0 version. This is the message I get when I ran that has the code forgment posted in previous message - "Unreachable catch block for NumberFormatException. It is already handled by the catch block for Exception". I am quite sure it doesn't make any difference whether you are using IDE or not, or may be which IDE you are using. Hope I corrected you if I am right. I think we both are right. but as that is an unreachable code, it gives us an explaination why it is unreachable (The answer given by you).