package com.itheima;
import java.util.ArrayList;
import java.util.Collections;
public class ExamTest17 {
public static void main(String[] args) {
ArrayList<Integer> al = new ArrayList<>();
boolean flag = true;
for (int a = 100; a < 1000; a++) {
flag = true;
for (int b = 2; b < a; b++) {
if (a % b == 0) {
flag = false;
break;
}
}
if (flag) {
al.add(a);
}
}
Collections.reverse(al);
System.out.println(al);
}
} |
|