How can i approach this?

there is another way??
my solution has accepted
import java.util.*;
public class Main {
public static void recu(char table[][], String ans , String val, int s, int len){
if(len==s){
System.out.println(ans);
return;
}
int digit=val.charAt(s)-‘0’;
for(int i=0;i<table[digit].length;i++){

			recu(table,ans+table[digit][i],val,s+1,len);

		
	}

}

public static void main(String args[]) {
	Scanner sc=new Scanner(System.in);
	String str=sc.next();
	int len=str.length();
	
	char table[][] = { {' '}, {'.','+','@','$'}, {'a','b','c'}, {'d','e','f'}, {'g','h','i'}, {'j','k','l'} , {'m','n','o'}, {'p','q','r','s'} , {'t','u','v'}, {'w','x','y','z'} };
	recu(table,"",str,0,len);





}

}

@Vipin_coder,
No your approach is the most optimized solution for this problem.

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.