I can't find the error in this code ... it is similar to the approach used in Vedic

import java.util.*;
public class Main {
public static void main(String args[]) {
System.out.print(pd(“abc”));

}
public static ArrayList<String> pd(String str){
    if(str.length()==0){
        ArrayList<String> s= new ArrayList<>();
        s.add(" ");
        return s;
    }
    char ch=str.charAt(0);
    String c =str.substring(1,str.length());
    ArrayList<String> st=pd(c);
    ArrayList<String> st1=new ArrayList<>();
    for(int i=0;i<=st.size();i++){
        String ans=st.get(i);
        int len=ans.length();
        for(int j=0;j<=ans.length();i++){
            String str1=ans.substring(0,i)+ch+ans.substring(i);
            st1.add(str1);

        }
        }
         return st1;


}

}

here is your corrected code:


if this solves your doubt please mark it as resolved