Good java solution


#1
    boolean[] nonPrimes = new boolean[A+1];

    for (int i = 2; i <= Math.sqrt(A); i++) {
        if(!nonPrimes[i]){
            for (int j = 2; j*i <=A ; j++) {
                nonPrimes[i*j]=true;
            }
        }
    }

    ArrayList<Integer> result=new ArrayList<>();
    for (int i = 2; i < nonPrimes.length; i++) {
        if(!nonPrimes[i]) result.add(i);
    }
    return result;