java Jumps in loop programming example:-

 

Jumps in loop programming example:-

Type of jumps loop

1.    break;

2.    continue;

break:- break is the terminated from the loop.

syntax:

for  (int i=1; i<=10; i++)   {

print(i)

if (i ==4)

break;

}

Q.p] write a java program to print the user given input 10 times but if the user gives input 4 then stop printing?

Program:

class  BreakExample    {

public static void main(String  args[])    {

for  (int  i=1;  i<=10; i++)     {

System.out.println(i);

if (i==4)

break;

}

}
}



Post a Comment

0 Comments