Expressions in statements must only be executed for their side-effects.

Hello !

I try to use a script in java to make a flashlight but i got this error.
This is the line:

 turnedOn != turnedOn;

Thank you for your anwsers.

Looks like you want to say

turnedOn = !turnedOn;

this will flip the boolean. What you are saying above is true does not equal true, which doesnt make sense logically. I bet the ! is just on the wrong side of the equal sign.