Notice below the simplicity of the Enhanced-For-Loop example below.

sumWithForLoop
int[] nums = {10, 20, 30, 40};
int sum = 0;

//Iteration using a basic for loop
for (int i = 0; i < nums.length; i++)
	sum += nums[i];

println("nums: " + Arrays.toString(nums));
println("sum: " + sum);
sumWithEnhancedForLoop
//Enhanced-For-Loop
//Demo here of a the nice and simple Java enhanced loop syntax
//Declare and initialize
int[] nums = {10, 20, 30, 40};
int sum = 0;

//Iteration with an "enhanced for loop" (much easier)
for (int eachNum: nums)
	sum += eachNum;

println("nums: " + Arrays.toString(nums));
println("sum: " + sum);