```
public List<List<Integer>> subsets(int[] nums) {
List<List<Integer>> subsets = new ArrayList<>();
subsets.add(new ArrayList<>());
for (int index = 0; index < nums.length; index++) {
int currentNum = nums[index];
List<List<Integer>> newSubsets = subsets.stream()
.map(subset -> {
List<Integer> newSubset = new ArrayList<>(subset);
newSubset.add(currentNum);
return newSubset;
})
.collect(Collectors.toList());
subsets.addAll(newSubsets);
}
return subsets;
}
```