Get a list of numbers from user return all possible permutat
Solution
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
 package chegg;
import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Scanner;
 public class Program {
  
 public static void permute(ArrayList l,int low,int high)
 {
 int i;
   
 if(low==high)
 System.out.println(l);
   
 for(i=low;i<=high;i++)
 {
 Collections.swap(l,low,i);
 permute(l,low+1,high);
 Collections.swap(l,low,i);
 }
   
 }
public static void main(String[] args)
 {
 Scanner input = new Scanner(System.in);
 int temp;
 ArrayList l1 = new ArrayList();
 while(true)
 {
 System.out.println(\"Input a number or enter -1 for quit.\");
 temp = input.nextInt();
 if(temp==-1)
 break;
 else
 l1.add(temp);
 }
   
 permute(l1,0,l1.size()-1);
 }
 }
![Get a list of numbers from user, return all possible permutations. For example, suppose we get number 1, 2, 3 from user, then we have [1,2,3], [1,3,2], [2,1,3]  Get a list of numbers from user, return all possible permutations. For example, suppose we get number 1, 2, 3 from user, then we have [1,2,3], [1,3,2], [2,1,3]](/WebImages/21/get-a-list-of-numbers-from-user-return-all-possible-permutat-1047837-1761545294-0.webp)
