• iconJava Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

Un Conditional Statements :

Java Control Statements

Un Conditional Statements allows you to direct the program's flow to another part of your program without evaluating conditions.
These are classified into following types.
1. continue
2. break




MSK TechnologiesTrainings

continue Statement:

'continue' statement is used to continue the loop( It skip the one iteration if the condition is true).

Syntax:
if(condition)
{
    continue;
}
    
Display Even Numbers Unsing Continue Statement
public class Main
{
    public static void main(String args[])
    {
        int x;
        for(x=1;x<=10;x++)
        {
            if(x%2!=0)continue;
            System.out.println(x);
        }
    }
}

                                

Output:
2
4
6
8
10
break Statement:

'break' statement is used to break the loop.

Syntax:
if(condition)
{
    break;
}
    
Break the loop which number divisible 2 and 3
public class Main
{
    public static void main(String args[])
    {
        int x;
        for(x=1;x<=10;x++)
        {
            if(x%2==0 && x%3==0)
            {
                break;
            }
            System.out.println(x);
        }
    }
}
                                

Output:
1
2
3
4
5