> Programming Question: Java?

Programming Question: Java?

Posted at: 2014-12-18 
sumOfAges += age;

is the same as

sumOfAges = sumOfAges + age;

The for loop goes through each element in ages and, for each iteration, age is assigned the value of that element.

Can someone please give me a step by step reasoning of these statements? What does += mean? Why is there a " : " in that for loop?

double sumOfAges= 0;

for (double age: ages) //There is an array to hold the ages which is double [] ages = new double [numberOfPeople];

sumOfAges += age;

This will compute the sum and the average number of ages. The program asks the user how many family members there are and what their ages are. At the end it computes the average of those ages in the family.

Thank you for your help!