classSolution{List<List<Integer>> ans =newArrayList<>();publicList<List<Integer>>subsets(int[] nums){List<Integer> list =newArrayList<>();
ans.add(list);find(nums, list,0);return ans;}// 寻找以 index 开头的子集publicvoidfind(int[] nums,List<Integer> fatherList,int index){for(int i = index; i < nums.length; i++){List<Integer> list =newArrayList<>(fatherList);
list.add(nums[i]);
ans.add(list);find(nums, list, i +1);}}}