来个容易接受点的
import java.util.*;
public class Text {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入一个数: ");
int num=in.nextInt();
System.out.println("2到这个数之间的质数是:");
for (int i = 2; i < num; i++) {
boolean f = true;
for (int j = 2; j < i; j++) {
if (i % j == 0) {
f = false;
break;
}
}
if (!f) {
continue;
}
System.out.print(i + "\t");
}
}
}