i saw how to break the loop (using label and break the label) .. but i want to break the first for loop depends on the second for loop :
for example :
public class HelloWorld {
static private int i;
public static void main(String[] args) {
int y = 20;
for (; y <= 30; y += 2)
{
System.out.printf("value of increamented y Value is %d\n", y);
increamentiValue();
}
}
private static void increamentiValue()
{
i = 0;
for (; i <= 5; i += 2) {
System.out.printf("value of i is %d\n", i);
}
}
}
for instance here i want to break the "y" loop depends on the number of iteration in "i" loop ..
for ex:
i want to break "y" for loop if the number iteriation in "i" loop is equal to 0 .. because in my program "i" checks the error ... in my ysytem error may occur any "i" .. if two times i dosnt have error (i==0) i want to break the "y" loop.
EX :
if
At y= 22 , i ==0; (no error occurs)
at y= 23 , i ==0; (no error occurs)
i dont want to proceed till 30. i want to break y loop .
>.int y=20;for(; y<=30...tofor(int y=20; j<=30.... It is easier to read and understand.forloop but put the initializer above it? Why use an instance variable in yourforloop?