1 package struct;
2
3 public class BreakDemo {
4 public static void main(String[] args) {
5 int i = 0 ;
6 while(i<100){
7 i++;
8 System.out.println(i);
9 if (i==30){
10 break;
11 }
12 }
13 System.out.println("123");
14 }
15 }
1 package struct;
2
3 public class ContinueDemo {
4 public static void main(String[] args) {
5 int i = 0 ;
6 while(i<100){
7 i++;
8 if (i%10==0){
9 System.out.println();
10 continue;
11 }
12 System.out.print(i);
13 }
14 }
15 }
1 package struct;
2
3 public class LabelDemo {
4 public static void main(String[] args) {
5 //打印101-150之间所有的质数
6 //质数是指在大于1的自然数中,除了1和它本身以外不再有其他因数的自然数。
7 int count =0;
8 //不建议使用!
9 outer:for (int i = 101; i < 150 ; i++) {
10 for (int j = 2; j < i / 2; j++) {
11 if (i % j == 0){
12 continue outer;
13 }
14 }
15 System.out.print(i+ " ");
16 }
17 }
18 }