int[] (Object[] array, Object element) { int[] tmp = new int[0]; int i = 0; int o = 0; while (i < array.length) { i = indexOf(array, element, i); if (i == -1) { break; } tmp = Arrays.copyOf(tmp, tmp.length + 1); tmp[o++] = i; i++; } return tmp; }