Question: I understand how mostly everything works in a loop in Java but I came to a realization that I am failing to understand one thing which is The Order a Loop Operates.

Basically I am failing to understand this because of this simple but boggling piece of code that was displayed in my class, the code is displayed below.

```
public class Test {
    public static void main (String[] args) {
        int sum = 0;
        for (int k = 1; k < 10; k += 2)
        {
            sum += k;
            System.out.print(sum + " ");
        }
    }
}

```

The output the program puts out is 1 4 9 16 25

Now I understand how it repeats and spits out the numbers but how does it go about even creating 1. Now you can say it created 1 by taking k and adding it to sum but shouldn't k be equaling 3? 

It goes k = 1; This sets k equal to 1. k < 10; Checks if k is less than 10. Then the question is when k += 2; Shouldn't k now equal to 3 but instead sum is now somehow equal to 1 after this operation occurred of adding 2 to 1, 2 + 1 = 3 but 3 + 0 = 1? How does this even go about.

My rationalizing for this is that any program I thought was to interpret code line by line or uniformly and not jumping around.

Overall my question is, how is sum equal to 1 when k is actually equal to 3.

Answer: 
The last condition, `k += 2` occurs *after* the first iteration of the loop.

So it's 

```none
k = 1, sum = 1
k = 3, sum = 4
k = 5, sum = 9
k = 7, sum = 16
k = 9, sum = 25

```
Let's break up your code. The keyword for just means loop. It will start @ 1 and continue as long as k is less than 10. It will also increase by `k+=2`. To translate, it means `k = k +2`

Inside the loop `sum = sum + k`. It will then print the value that sum has plus a space.

```
k = 1, sum = 1
k = 3, sum = 4
k = 5, sum = 9
k = 7, sum = 16
k = 9, sum = 25

```

and keep repeating. Let me know if you still have trouble grasping this concept