• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use Of Continue in do While Loop

 
Aniruddha Jadhao
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is there no use of continue in do While loop?

please look in following code

public class Continue {

public static void main(String [] a){
boolean flag =true;
int i=0;
do{
flag= false;
System.out.println(i++);
flag = i<10;

continue;//here with it/with out the same out put

}while(flag?true:false);
}
}
 
S Thiyanesh
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A continue statement will always check the condition in loops and proceeds the next iteration.
In your example, the continue statement will not bypass the loop condition.

try


Hope this one does the purpose of printing only the values of i >= 5 and i <= 10
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic