Shift + Enter · Start / restart
कोड प्रॉम्प्ट मार्गदर्शक वाचा
- प्रोग्रामिंग भाषा
- Java
- अडचण
- मध्यम
Traverse a list and calculate its total.
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Integer> values = List.of(4, 8, 15, 16);
int total = 0;
for (int value : values) {
total += value;
}
System.out.println(total);
}
}