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);
}
}