I’m trying to use / in a for loop as the action to complete after each iteration, but I’m getting an "invalid AssignmentOperator" error. I’m using Java SE 17.
Here’s the relevant code:
for (i = num/2; i >= 0; i / 2) {
}
All variables are integers and already defined. The error continues even if I make the first statement one that doesn’t use /, so it’s not an issue with i being assigned to num/2 (other than any problems that may be happening with the / symbol itself).
Why am I getting this error?
>Solution :
i / 2 is not an assignment operation.
Try i /= 2 or i = i/2