lundi 6 mars 2017

Nested if statement issue with string [on hold]

Can someone explain to me why this doesnt work? My understanding is that if the first "if" statement is false then the second one should be evaluated. My hunch is that strings cant be evaluated by if? The output I am expecting is,

"It is a nice day"

String sky;
    boolean rain;

    sky = "grey";
    rain = false;

if (sky.equals("blue") ) {
    System.out.println("sky is blue");
    if (rain = false) {
        System.out.println("It is a nice day");
    }
}

I looked at some other sources but still not sure what the issue is.

Aucun commentaire:

Enregistrer un commentaire