// "static void main" must be defined in a public class.publicclassMain {privatestaticvoidgetSubsets(List<Integer> superSet,int k,int idx,List<Integer> current,List<List<Integer>> solution) {if (current.size() == k) {solution.add(newArrayList<>(current));return; }for (int i = idx; i <superSet.size(); i++) {Integer x =superSet.get(i);current.add(x);getSubsets(superSet, k, i +1, current, solution);current.remove(current.size() -1); } }publicstaticList<List<Integer>> getSubsets(List<Integer> superSet,int k) {List<List<Integer>> res =newArrayList<>();getSubsets(superSet, k,0,newArrayList<Integer>(), res);return res; }publicstaticvoidmain(String[] args) {int k =3;List<Integer> superSet =newArrayList<>();superSet.add(1);superSet.add(2);superSet.add(3);superSet.add(4);superSet.add(5);List<List<Integer>> res =getSubsets(superSet, k);System.out.println(res); }}