Here you can find the source of booleanArrayToIntIndexes(boolean[] arrb)
public static int[] booleanArrayToIntIndexes(boolean[] arrb)
//package com.java2s; public class Main { /**/*from w ww . j a va 2 s . c o m*/ * Set elements of arrb true if their indexes appear in arrb. */ public static int[] booleanArrayToIntIndexes(boolean[] arrb) { int count = 0; for (int i = 0; i < arrb.length; i++) { if (arrb[i]) { count++; } } int[] intarr = new int[count]; count = 0; for (int i = 0; i < arrb.length; i++) { if (arrb[i]) { intarr[count++] = i; } } return intarr; } }