Array out of bound error and run time error in code

public class keypad_ques {

public static ArrayList<String> GetCodes(String str,String[] table)
{
    if(str.length()==0)
    {
        ArrayList<String> base=new ArrayList<>();
        base.add("");
        return base;      
    }
    int i1=(int)str.charAt(0);

// String s1=table[i1];
String ros=str.substring(1);
ArrayList recres = GetCodes(ros, table);
String s1=table[i1];

    ArrayList<String> myres=new ArrayList<>();
    for(int i=0;i<recres.size();i++)
    {
        for(int j=0;j<s1.length();j++)
        {
            myres.add(recres.get(i)+s1.charAt(j));
        }
    }
    return myres;
}

public static void main(String[] args) {
    
    Scanner sc=new Scanner(System.in);
    String str=sc.nextLine();
    
    String table[] = { " ", ".+@$", "abc", "def", "ghi", "jkl" , "mno", "pqrs" , "tuv", "wxyz" };
    System.out.println(GetCodes(str, table)); 
}

}
on netbeans, I’m getting out of bound error and on coding blocks ide, run time error. I don’t see any problem while dry running. where is the mistake?

Also, is it a good way to write code in which recursive function has for loops?

error is becoz of when u r converting char to int
it is converting that char to its ascii value
pls see this by printing ur i1 value

to convert a integer char to its int value

int i1= int i1=(int)(str.charAt(0)-β€˜0’);

minus the ascii value of char β€˜0’

hope this will help u
pls rate my work