Scrivi un programma Java per stampare tutte le permutazioni di un array.
import java.util.Arrays;

public class Permutazioni {
	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;
	}
}