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:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html

It states:

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

Also look at the Processing references:
Reference / Processing.org

image

Have fun!

:)

1 Like