you misunderstood the the series in the question. what they mean is that the i-th element of the series is given by:
((-1)^i+1)/(2i - 1) [i starting with 1 in this notation]
so the series up until element 2 is:
4 * ( -1^(1+1) / (2*1-1) + -1^(2+1) / (2*2-1) ) = 4*(1 - 1/3)
so the question lists the 1st 6 elements in the series, but the series is infinite in length. that means that for a given value of i (TARGET) the calculation would look like:
double sum = 0;
for (int i=1; i<TARGET; i++) {
double element = Math.pow(-1,i+1) / (2*i + 1); //element i
sum += element; // add element i to the results so far
}
double result = 4*sum;
see wikipedia for a more details description of this series (note, the wikipedia article starts counting at i=0)