Syntax error on token "-", invalid AssignmentOperator
14,804
Solution 1
Maybe you forgot the equal sign
for (int iI = 4; iI > 0; iI--)
faAmount[iI] -= faAmount[iI - 1];
Or to assign the difference in a variable
double x = 0; //or another value
for (int iI = 4; iI > 0; iI--)
x = faAmount[iI] - faAmount[iI - 1];
Solution 2
faAmount[iI] - faAmount[iI - 1]
is n expression that have a result, but you don't assign it to anything, this is invalid in Java.
Solution 3
The technical explanation is that faAmount[iI] - faAmount[iI - 1]
is an expression but isn't a statement. The JLS notes that
Unlike C and C++, the Java programming language allows only certain forms of expressions to be used as expression statements.
An additive expression is not one of those expressions that are also statements.
Author by
Riemke Shabadoo
Updated on June 14, 2022Comments
-
Riemke Shabadoo almost 2 years
for (int iI = 4; iI > 0; iI--) faAmount[iI] - faAmount[iI - 1];
This is the code it's in. How can I fix this?