Answer:
see explaination
Step-by-step explanation:
public class test{
public static void main(String[] args){
boolean flag[] = new boolean[1000];
for(int i = 0; i < 1000; i++){
flag[i] = true;
}
for(int i = 2; i < 1000; i++){
if(flag[i] == true){
for(int j = i + 1; j < 1000; j++){
if(j % i == 0) flag[j] = false;
}
}
}
System.out.println("The prime numbers in the range 0 to 1000 are:");
for(int i = 2; i < 1000; i++){
if(flag[i] == true) System.out.print(i + " ");
}
}
}