dimanche 29 avril 2018

if-statement with continue or break

I'm doing the simulation of Java OCA test. During my study with the book "OCA - Study Guide" (Sybex), at the second chapter there is the following (Table 2.5, page 91): if - allows break statement: NO if - allows continue statement: NO

But during the simulation of Java OCA test, did by Sybex (online book OCA), there is this question:

int  x= 5;
    while (x>=0) {
        int y = 3;
        while (y>0) {
            if (x<2)
                continue;
            x--; y--;
            System.out.println(x*y + " ");
        }
    }

My answer was: It doesn't compile But the correct answer is: 8 3 0 2

What is the correct information? What is right (book or simulation test)?

Thanks a lot!

Aucun commentaire:

Enregistrer un commentaire