I've been trying to find some help on how to use the Sieve of Erastothenes to print the primes from 2 to 1000 using an array. I looked up how the Sieve works but am having trouble figuring out how to code it.
import java.util.*;
public class PrimeArray {
public static boolean isPrime(int n){
if(n<=1){
return false;
}
for(int i = 2; i*i<n; i++){
if(i%n==0)
return false;
}
return true;
}
public static void main(String[] args) {
int[] array = new int[1000];
for(int j = 2; j<array.length; j++){
if(isPrime(j))
System.out.println(array[j]);
}
}
}