Print all string permutation

package learn_java;
import java.util.*;
class A_class{
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
char s[]=new char[20];
int n=sc.nextInt();
for(int i=0;i<n;i++) {
s[i]=sc.next().charAt(0);
}
permut(s,n,0);
}
static void permut(char s[],int n,int i) {
if(s[i]==’\0’) {
System.out.print(s.toString()+" ");
return;
}
for(int j=i;j<n;j++) {
char t=s[i];
s[i]=s[j];
s[j]=t;
permut(s,n,i+1);
t=s[i];
s[i]=s[j];
s[j]=t;
}
}
}

i m not getting correct answer.

@Affan-Mokarram-202031887744398


I have made this code work for int input
Please look how to make it work with char

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.