compute sum of negative elements of one-dimensional array which contain float elements
public static double computeSumOfNegativeElements(float[] array) { double result = 0; for (int i = 0; i < array.length; i++) { if (array[i] < 0) { result = result + array[i]; } } return result; }