ArrayList Iteration and Product
What is the output when the following code is executed?
import java.util.ArrayList;
public class WrapperTest {
public static void main(String[] args) {
ArrayList<Double> list = new ArrayList<>();
list.add(2.0);
list.add(3.0);
list.add(4.0);
double result = 1;
for (Double d : list) {
result = result * d;
}
System.out.println(result);
}
}
A
24.0
B
9.0
C
Compilation Error
D
2.0
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE