Ответ: Импорт сверху лишний — тестировал.
Ответ:
import java.util.Arrays;
public class ArrayHandler {
static double[] handle(double[] array) {
double sum1 = 0.0;
for(int i = 1; i < array.length; i+=2)
sum1 += array[i];
System.out.println(sum1);
double sum2 = 0.0;
int negPos1 = -1, negPos2 = -1;
for(int i = 0; i < array.length; i++)
if(array[i] < 0)
if(negPos1 == -1)
negPos1 = i;
else
negPos2 = i;
if(negPos2 != -1)
for(int i = negPos1 + 1; i < negPos2; i++)
sum2 += array[i];
System.out.println(sum2);
int iter = 0;
double[] temp = new double[array.length];
for(double v : array)
if(v > 1 || v < -1)
temp[iter++] = v;
double[] result = new double[iter];
System.arraycopy(temp, 0, result, 0, iter);
return result;
}
}