java - Assign true or false value one after another -
i got question assignment, can't find solution this..
this array declares 12 variables..
boolean[] rowofrotatoes = new boolean[12]; now have assign true , false value 1 after another,
rowofrotatoes[0] = true; rowofrotatoes[1] = false; rowofrotatoes[2] = true; rowofrotatoes[3] = false; rowofrotatoes[4] = true; .... rowofrotatoes[9] = true; rowofrotatoes[10] = false; rowofrotatoes[11] = true; but have use loop this!
they have given me structure fill in blanks..
int plantingspace = 0; while(plantingspace < 12) { rowofrotatoes[plantingspace] = <fill space 1> <fill space 2> <fill space 3> == 0; ++plantingspace; } how use above structure assign true , false values 1 after another?
to strictly fill spaces requirement dictates:
int plantingspace = 0; while (plantingspace < 12) { rowofrotatoes[plantingspace] = plantingspace % 2 == 0; ++plantingspace; }
Comments
Post a Comment