samedi 25 novembre 2017

Java - not able to set boolean to false? What is wrong with this [duplicate]

I made a class called ball, and it has this method called pass --

public void pass(boolean a) {

    if (a = false) {
        System.out.println("Oops");
    }       

}

When I make a new object call ball thought, and execute the method like this --

ball.pass(false);

And when I run it, it doesn't show anything. HOWEVER, when I change all of the falses to trues

 if(a = true) and ball.pass(true)

The system out println will work... I have done multiple experimentations with this, and I am not at specifying my questions so I couldn't find my answer on the web.

Aucun commentaire:

Enregistrer un commentaire