void generate(int[] a, boolean[] b, List<List<Integer>> list, int n) {
        if (n == 0) {
            List<Integer> l = new ArrayList<>();
            for (int i = 0; i < a.length; i++)
                if (b[i]) l.add(a[i]);
            list.add(l);
        } else {
            b[n - 1] = true;
            generate(a, b, list, n - 1);

            b[n - 1] = false;
            generate(a, b, list, n - 1);
        }
    }
This generates all subsets of given set.
src/problems/medium/SubSets.java