All test case failed i don't know why

static ArrayList getPermutation(String S) {
if (S.length() == 0) {
ArrayList bc = new ArrayList();
bc.add("");
return bc;
}
ArrayList myres = new ArrayList();

	char cc = S.charAt(0);
	String ros = S.substring(1);
	ArrayList<String> recres = getPermutation(ros);

	for (String str : recres) {
		for (int i = 0; i <= str.length(); i++) {
			String ans = str.substring(0, i) + cc + str.substring(i);

			myres.add(ans);

		}
	}
	Collections.sort(myres);
	return myres;
}

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	ArrayList<String> res = getPermutation(S);
	char ch = S.charAt(0);
	for (String string : res) {
		if (string.charAt(0) != ch)
			System.out.println(string);
	}
}

@nigamshubham1998,
I see that you have successfully submitted this question. Do you have any further doubts on this question?

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.