Summing The Elements of An Array
by
, January 29th, 2012 at 05:02 PM (2493 Views)
Say we have an array with ten indices. Below is how we can calculate the sum of these indices.
Firstly, initialise your array. Then, create a variable to store the total. A simple For Loop set to iterate to the length of our array will do the trick. All you need to do is set the total to the total plus the array with the index if the current counter. A very simple concept.
In an unrelated topic, I'm now up to my 30th Java tutorial. I'm making some nice leadway here, though I've still got a heck of a lot to learn.