int selectedItemsNum = 0; for (int i = 0; i < numOfItems; i++) { if (selectedItems[i] == true) { selectedItemsNum++; } }
int selectedItemsCount = 0; for (int i = 0; i < selectedArray_return.length; ++i) { selectedArray_return[i] = (i<numOfItems) ? items[i].isSelected() : false; if (selectedArray_return[i]) { ++selectedItemsCount; } }
  public int getSelectedFlags(boolean[] selectedArray_return)  {		if (selectedArray_return == null) {			throw new NullPointerException();		}		if (selectedArray_return.length < numOfItems) {			throw new IllegalArgumentException();		}		System.arraycopy(selectedItems, 0, selectedArray_return, 0, numOfItems);		int selectedItemsNum = 0;		for (int i = 0; i < numOfItems; i++) {			if (selectedItems[i] == true) {				selectedItemsNum++;			}		}    return selectedItemsNum;  }