A condition expression should not be reduced to an assignment

boolean check(){
for (int j = 0; j < grid.size(); j++) {
   
      if (grid.get(j-1).visited = true
      ) {
      return true;
      }
    }
}

i want run some fuction after the class in a arraylist all been visited.
then this come up"a condition expression should not be reduced to an assignment"
i know it will return true after every check.but i really dont know what to do.

Use == here for condition

1 Like

Hello,

Take a look here:
Equality, Relational, and Conditional Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

It states:

Keep in mind that you must use " == ", not " = ", when testing if two primitive values are equal.

Also look at the Processing references:
Language Reference (API) \ Processing 3+

image

Have fun!

:)

1 Like