code: private static int getPowerSet(int[] set, int inputIndex, int[] sofar, int[][] sets, int outputIndex) {
          for (int i = inputIndex; i < set.length; i++) {
              int n = sofar == null ? 0 : sofar.length;
              if (n < set.length-1) {
                  int[] subset = new int[n + 1];
                  subset[n] = set[i];
                  if (sofar != null) {
                      System.arraycopy(sofar, 0, subset, 0, n);
                  }
  
                  sets[outputIndex] = subset;
                  outputIndex = getPowerSet(set, i + 1, subset, sets, outputIndex + 1);
              }
          }
  
          return outputIndex;
      }
docs: Recursively calculates all possible subsets.
  @param set the input item set.
  @param inputIndex the index within the input set marking current
  element under consideration (0 at start).
  @param sofar the current combination determined sofar during the
  recursion (null at start).
  @param sets the power set to store all combinations when recursion ends.
  @param outputIndex the current location in the output set.
  @return revised output index.