Napište program v jazyce Java, který vytiskne všechny permutace pole.
import java.util.Arrays;

public class Permutations {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3};
        permute(arr, 0);
    }

    public static void permute(int[] arr, int index) {
        if (index >= arr.length - 1) {
            System.out.println(Arrays.toString(arr));
        }

        for (int i = index; i < arr.length; i++) {
            swap(arr, index, i);
            permute(arr, index + 1);
            swap(arr, index, i);
        }
    }

    public static void swap(int[] arr, int i, int j) {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}