• iconJava Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

Unconditional Statements:
UnConditional 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

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

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(condion)
{
break;
}

Break the loop which number divisible 2 and 3

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