Home Java Java-get-example Java error unreachable statement



Java error unreachable statement
Posted on: November 3, 2008 at 12:00 AM
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.;.

Java error unreachable statement

     

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


or="#7f0055">import java.util.*;

public class unreachableerror {

  public static void main(String arg[]) {
  for (int i = 0; i <= 5; i++)
  {
  System.out.println(i);
  continue;
  System.out.println(i);

  }
  }
}

On the execution of a program, the output on the command prompt is  displayed as
Output

Compiling source file to /home/girish/NetBeansProjects/errors/build/classes
/home/girish/NetBeansProjects/errors/src/
unreachableerror.java:
11: unreachable statement
  System.out.println(i);
error
BUILD FAILED (total time: seconds)

To resolve this error remove continue; from this program

Download code

Related Tags for Java error unreachable statement:
cooperrorideclassanthelpintegermethodvariablelooptutorialstatenameintriathisidaiooforstatementtoeachemaindesvarinasstamntsidsidewanclesemmedescribetorsatishaeaandarstatcodcodeunderstandingwantvatutorscrssrithavstabablhatndodeo


More Tutorials from this section

Ask Questions?    Discuss: Java error unreachable statement   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.