English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What is the effect of putting a continue statement in a if statement, which is inside of a for each loop? Does it just go to next element?

2007-12-09 03:30:50 · 2 answers · asked by justgenius12 7 in Computers & Internet Programming & Design

2 answers

The continue statement in a loop means "skip the rest of the statements in the loop and go to the next iteration".

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html

2007-12-09 04:42:58 · answer #1 · answered by daa 7 · 0 0

the continue will tell the loop to skip the rest of the code in that loop and go on to the next loop

for example:

for(int i=0;i < 5;I++)
{

if(i % 2 == 0 )
{
continue;
}

System.out.println(i+"\n");
}

this would out put all the numbers from 0 to 4 skipping the even:

1
3

cheers

2007-12-09 04:45:12 · answer #2 · answered by Perro H 3 · 0 0

fedest.com, questions and answers