In this Tutorial we want to describe you a code that help you in understanding a unreachable statement. For this we have a class name' unreachable error', Inside the main method we have a for loop that has a variable integer I.;. The System.out.println is used to display the value of variable integer i on command prompt. The continue statement in the code prevent from the normal execution of the code. The only difference between the continue and break statement is that break statement exits the control of the expression from the loop, but continue statement put the expression in the loop but without executing the code written after the continue statement. This code show you how the statement become unreachable after continue statement.
unreachableerror.java
|
|
Compiling 1 source file to /home/girish/NetBeansProjects/errors/build/classes /home/girish/NetBeansProjects/errors/src/ unreachableerror.java:11: unreachable statement System.out.println(i); 1 error BUILD FAILED (total time: 0 seconds) |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java error unreachable statement View All Comments
Post your Comment