```
public List<List<Integer>> subsets(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
subsets(nums, 0, new ArrayList<>(), result);
return result;
}
private void subsets(int[] nums, int start, List<Integer> solution, List<List<Integer>> result) {
if (start == nums.length) {
result.add(new ArrayList<>(solution));
return;
}
subsets(nums, start + 1, solution, result);
solution.add(nums[start]);
subsets(nums, start + 1, solution, result);
solution.remove(solution.size() - 1);
}
```