2 test cases not passing in dictionary order smaller

I am not using sort and checking the output generated by recursion with my initial string. Still, I am getting the wrong answer. Please resolve my doubt
import java.util.*;
public class Main {
ArrayList perm(String s) {
ArrayList a = new ArrayList<>();
if (s.length() == 0) {
ArrayList list = new ArrayList();
list.add(s);
return list;
}
char c = s.charAt(0);
String s1 = s.substring(1);
ArrayList b = perm(s1);
int pos;
for (int i = 0; i < b.size(); i++) {
pos = 0;
while (pos <= b.get(i).length()) {
String res = b.get(i).substring(0, pos) + c + b.get(i).substring(pos);
a.add(res);
pos++;
}
}
return a;
}

public static void main(String args[]) {
    // Your Code Here
    Main m = new Main();
    Scanner obj = new Scanner(System.in);
    String str = obj.next();
    ArrayList<String> c = new ArrayList<>();
    c = m.perm(str);
  //  System.out.println(c);

    // System.out.println(c);
    int index=0;
    for(int i=0;i<c.size();i++)
    {
        if(c.get(i).equals(str))
            continue;

        if((int)c.get(i).charAt(0)<(int)str.charAt(0))
            System.out.println(c.get(i));
        if((int)c.get(i).charAt(0)==(int)str.charAt(0))
        {
            if((int)c.get(i).charAt(1)<(int)str.charAt(1))
                System.out.println(c.get(i));
        }
    }

}

}

Hi,you can have a look at this .Hope it will help you.

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.