fork download
  1. class Util
  2. {
  3. public static void main(String[] args)
  4. {
  5. int[] A = { 1, 2, 3, 4, 5 };
  6.  
  7. int sum = 0;
  8. for (int i: A)
  9. sum += i;
  10.  
  11. System.out.println("The sum of all elements in the array is " + sum);
  12. }
  13. }
Success #stdin #stdout 0.08s 27796KB
stdin
Standard input is empty
stdout
The sum of all elements in the array is 15