java for loop without condition code example
Example 1: continue in java
int i = 0;
while (i < 10) {
if (i == 4) {
i++; //why do I need this line ?
continue;
}
System.out.println(i);
i++;
}
Example 2: labeled for loop in java
//WithLabelledLoop.java
class WithLabelledLoop
{
public static void main(String args[])
{
int i,j;
loop1: for(i=1;i<=10;i++)
{
System.out.println();
loop2: for(j=1;j<=10;j++)
{
System.out.print(j + " ");
if(j==5)
break loop1; //Statement 1
}
}
}
}
Output :
1 2 3 4 5