Our social:

Wednesday, October 5, 2016

Continue Statement in Java-Tutorial

Sometimes it is needed to go to iteration part before even completing the whole block of statements in the loop. Then continue is useful.
Example: suppose we need to develop a code where we will print only the odd numbers from 1 to 10
So conitnue skips the further statements to execute and jumps to the next iteration of the loop.
public class ContinueDemo {

 public static void main(String[] args) {

  for(int i = 0; i<=10; i++){
   System.out.print(i+" ");
Try It
In the above code, when the process encounters continue, it doesn’t execute the print statement. Instead it goes back to the iteration process.
The output will be:
1 3 5 7 9


Return Statement in Java


Post a Comment

Hello Every One thanks For Visit My site You Can Suggest any Idea About site And Related Education Information Provide me Its Best Content For you am Include in this Site And feel free contact And email now I hope This site very help full you