Java break statement:
package javaapplication27;public class BreakDemo {
public static void main(String[] args) {
for(int i=0;i<=100;i++){
if(i==10)break; //break loop if i is 10;
System.out.println("i"+i);
}
System.out.println("loop complete.");
}
}
The output of this program is:
run:
i0
i1
i2
i3
i4
i5
i6
i7
i8
i9
loop complete.
0 comments:
Post a Comment