I am trying to write a method that when invoked, changes a boolean variable to true, and when invoked again, changes the same variable to false, etc.
For example: call method -> boolean = true -> call method -> boolean = false -> call method -> boolean = true
So basically,
if (a = false) { a = true; }
if (a = true) { a = false; }
I am not sure how to accomplish this, because every time I call the method, the boolean value changes to true and then false again.
a = false
is setting a to false, not testing it. usea == false
or better yet!a
to test if a boolean is false.