Why not just keep track of the elements in the array via some counter... then the loop is not neccessary...