Online Examination System for all learner!!! coming soon..

JAVA : Program to discuss the difference between Break and Continue.

 
Break and Continue
The keywords break and continue keywords are part of control structures in Java. Sometimes break and continue seem to do the same thing but there is a difference between them.  The break keyword is used to breaks(stopping) a loop execution, which may be a for loop, while loop, do while or for each loop. The continue keyword is used to skip the particular recursion only in a loop execution, which may be a for loop, while loop, do while or for each loop.

Code:

class breakandcontinue
//for more program please visit www.programtubenotes.blogspot.in
{
    public static void main(String args[])
    {
        // Illustrating break statement (execution stops when value of i becomes to 4.)
        System.out.println("Break Statement\n....................");

        for(int i=1;i<=5;i++)
        {
            if(i==4) break;
            System.out.println(i);
        }

        // Illustrating continue statement (execution skipped when value of i becomes to 1.)
        System.out.println("Continue Statement\n....................");

        for(int i=1;i<=5;i++)
        {
            if(i==1) continue;
            System.out.println(i);
        }
    }
}

Output:

Break Statement
....................
1
2
3
Continue Statement
....................
2
3
4
5

<<Previous Page                     Download Code                    Next Page>> 

Related JAVA Programs:

  1. Write a JAVA program to print "Hello World".
  2. Write a JAVA program to find sum of all integer greater than 100 and less than 200, that are divisible by 5.
  3. Write a JAVA program to show how method overriding helps in dynamic method dispatch.
  4. Write a JAVA program to Serach and Delete a specific element from an integer array.
  5. Write a JAVA program to illustrate how super keyword is used to call the parent class constructor within the child class.
  6. Write a JAVA program illustrating parameterized constructor.
  7. Write a JAVA program to create and access a user defined packages.
  8. Write a JAVA program to calculate the length of a string.
  9. Write a JAVA program to findout the number of Vowels present in the input string.
  10.  JAVA Program that implements the Concept of Encapsulation.


C Programming Online Test 1

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...