samedi 14 septembre 2019

if (count % 2 == 1)?

I am unsure of how this code works with the (count % 2 == 1) and what the output is supposed to be according to it. Any clarification would be great!

Scanner s = new Scanner("d 1 o 2 g 3 c 7 t");
int count = 0;
while(s.hasNext())
{
if (count % 2 == 1)
System.out.print(s.next() + " ");
else
s.next();
count++;
}

Aucun commentaire:

Enregistrer un commentaire