← Back to Question List
Java Code Walkthrough #23
Array Sum with Enhanced For
📄 Code
Read carefully — what does this print?1public class Main {2 public static void main(String[] args) {3 int[] values = {2, 4, 6, 8};4 int total = 0;5 for (int v : values) {6 total += v;7 }8 System.out.println(total);9 System.out.println(total / values.length);10 }11}