int[] () { int count = 0; for (boolean checkedMark : myCheckedMarks) { if (checkedMark) { count++; } } int[] rows = new int[count]; int currentRow = 0; for (int idx = 0; idx < myCheckedMarks.length; idx++) { if (myCheckedMarks[idx]) { rows[currentRow++] = idx; } } return rows; }