For this Question: A ​ permutation is simply a name for a reordering. So the permutations of the string
‘abc’ are ‘abc’, ‘acb’, ‘bac’, ‘bca’, ‘cab’, and ‘cba’. Note that a sequence is a
permutation of itself (the trivial permutation). For this problem, you’ll need
to write a ​ recursive​ function ​​ that takes a string and returns a
list of all its permutations.
A couple of notes on the requirements:
1. The order of the returned permutations must be lexicographically.
2. Avoid returning duplicates in your final list.Input contains a single string S.

Constraints:-
1<=|S|<=8Print all the permutations of string S in lexicographical order.Sample Input: 
ABC

Sample Output :
ABC ACB BAC BCA CAB CBA

Explanation:
all permutation are arranged in lexicographical order .

Sample Input:
(T(

Sample Output:-
((T (T( T((, I have written this Solution Code: import java.io.*;
import java.util.*;
import java.util.Arrays;

class Main
{
	 public static void main(String[] args)
    {
		Scanner sc= new Scanner(System.in);
        String str = sc.next();
		if(str.length()==1)
		System.out.print(str);
		else
        permutations(str);
    }
	   public static void permutations(String str)
    {
        char[] charstr = str.toCharArray();
        Arrays.sort(charstr);

        while (true)
        {
            System.out.print(new String(charstr) + " ");

            if (!next_String(charstr)) {
                break;
            }
        }
    }
     static void swap(char[] charstr, int i, int j)
    {
        char ch = charstr[i];
        charstr[i] = charstr[j];
        charstr[j] = ch;
    }

     static void reverse(char[] charstr, int start)
    {
        for (int i = start, j = charstr.length - 1; i < j; i++, j--) {
            swap(charstr, i, j);
        }
    }
    public static boolean next_String(char[] charstr)
    {

        int i = charstr.length - 1;
        while (charstr[i - 1] >= charstr[i])
        {
            if (--i == 0) {
                return false;
            }
        }

        int j = charstr.length - 1;
        while (j > i && charstr[j] <= charstr[i - 1]) {
            j--;
        }

        swap(charstr, i - 1, j);

        reverse(charstr, i);

        return true;
    }



}, In this Programming Language: Java, Now tell me if this Code is compilable or not?