dimanche 6 décembre 2015

To which if does given else-if belong to?

given that x = 1, y = -1, z = 1;

 if (x > 0)
       if (y > 0)
          System.out.println("x > 0 and y > 0");
    else if ( y< 0)
          System.out.println("x < 0 and z > 0");

This code prints x < 0 and z > 0; How is this possible?To which if does given else-if belong to?

Aucun commentaire:

Enregistrer un commentaire