Computer Science, asked by sushreya, 1 year ago

state the difference between break and continue keywords in java

Answers

Answered by siddhartharao77
2
Break -  The break statement immediately jumps to the end of the appropriate statement.

Continue - 
The continue statement immediately jumps to the next iteration of the appropriate loop.


Ex: Break :

    
class Break
{
    public static void main(String args[])
    {
        for(int i=1;i<=5;i++)
        {
            if(i==4)
            break;
            System.out.println(i);
        }


Ex: Continue :

class Continue
{
    public static void main(String args[])
    {
     for(int i=1;i<=5;i++)
        {
            if(i==4)
            continue;
            System.out.println(i);
        }



Hope this helps!
Similar questions