int[] arr = new int[] { 0, 1, 2, 3, 4, 5 };
List<Integer> l = new ArrayList<>();
int N = 4;
public void combination(int i) {
if (l.size() == N) {
System.out.println(Arrays.toString(l.toArray(new Integer[0])));
return;
}
for (; i < arr.length; i++) {
l.add(arr[i]);
combination(i + 1);
l.remove(l.size() - 1);
}
}
public static void main(String[] args) {
WA wa = new WA();
// wa.WholeArrangement(5);
wa.combination(0);
}