The for-statement is a convenient way of expressing iteration. This fits well when you know how to express the range of values over which the iteration variable should iterate. The class SumZ contains a very simple for-loop summing the five elements of the vector z.
Since the scope of the iteration variable is the body of the for-statement, it may hide other variables with the same name, like the constant k in HideVariable.