```
public List<List<Integer>> subsets(int[] arr) {
if (arr == null )
return new ArrayList<>();
List<List<Integer>> subsets = new ArrayList<>();
int setSize = (int) Math.pow(2, arr.length);
for (int i = 0; i < setSize; i++) {
int index = 0;
int j = i;
List<Integer> set = new ArrayList<>();
while (j != 0) {
if ((j & 1) == 1) {
set.add(arr[index]);
}
index++;
j = j >> 1;
}
subsets.add(set);
}
return subsets;
}
```