This is in Eclipse. I wrote this code that is supposed to sum each String
element within the ArrayList
and then return the sum cubed. The problem is that it is returning 0.0 every time the method is run with strings added to it.
I don't understand why on line 6 the loop is not computing the length of each string element and storing the value to sum1
.
public static double q1(ArrayList<String> input1) {
ArrayList<String> array1 = new ArrayList<String>();
double sum1 = 0;
for (String s1: array1) {
sum1 += s1.length(); //Line 6
}
return Math.pow(sum1, 3);
}