int[] tab = {4, 2, 6, 1, 15}; int suma = 0; int i = 0; for (int x : tab) { suma += tab[i]; i++; } System.out.println(suma);