You have said to print it twice;
for (int i = 0; i <= 2; i++)
This says,
a) Create a variable named
i and set the value to
zero.
b) Execute the loop and increment
i by
1
c) Do this while
i is less than
2
Hence, it completes the loop twice, once for i = 0 & again for i = 1
Kind Regards