I have this simple piece of code but I don't understand this part: sum += i++ .
int num1 = 5;
int sum = 0;
if (num1 < 100) {
for (int i = 0; i < num1; i++)
sum += i++; //?
System.out.println("sum = " + sum);
} else {
sum = -1;
}
System.out.print(sum);
The result I get is 6 and I don't understand how and why.