dimanche 1 octobre 2017

Confused on how to evaluate the while !result in the while function

I'm not sure how to evaluate this line to understand what my code does while (i < data.length && !result) {

this is my full code.

public static boolean {2,6,-3,7,3} (int[] data, int val) {

boolean result = false;
int i = 0;

while (i < data.length && !result) {
    if (data[i] == val) {
        result = true;
    }
    i++;
}

return result;

}

Aucun commentaire:

Enregistrer un commentaire