Whats problem in my code

import java.util.*;
public class Main {
static Map<String, String> phone = new HashMap<String, String>() {{
put(“0”," “);
put(“1”,”.+@$");
put(“2”, “abc”);
put(“3”, “def”);
put(“4”, “ghi”);
put(“5”, “jkl”);
put(“6”, “mno”);
put(“7”, “pqrs”);
put(“8”, “tuv”);
put(“9”, “wxyz”);
}};
static String searchIn [] = {
“prateek”, “sneha”, “deepak”, “arnav”, “shikha”, “palak”,
“utkarsh”, “divyam”, “vidhi”, “sparsh”, “akku”
};

	  static ArrayList<String> output = new ArrayList<String>();
	   public static void backtrack(String combination, String next_digits) {
	    if (next_digits.length() == 0) {
	
	      output.add(combination);
	    }
	    else {
	      
	      String digit = next_digits.substring(0, 1);
	      String letters = phone.get(digit);
	      for (int i = 0; i < letters.length(); i++) {
	        String letter = phone.get(digit).substring(i, i + 1);
	        
	        backtrack(combination + letter, next_digits.substring(1));
	      }
	    }
	  }

  public static void advancedKeypad(String str) {
		  if (str.length() != 0)
		      backtrack("", str);
			  for(String a:output) {
				  for(String i:searchIn) {
				  if(check(a,i,0,0))
					  System.out.println(i);
			  }
		  }

}
public static boolean check(String str, String name,int i,int j) {
int temp=0;
while( name.length()-str.length()!=j) {
j=temp;
i=0;
temp=j+1;
for(int a=0;a<str.length();a++) {
if(str.charAt(i)==name.charAt(j)) {
i++;j++;
if(a==str.length()-1) {
return true;
}
}else {
break;
}
}
}
return false;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
advancedKeypad(str);
}
}

@sksumitkumardiwaker,
for the input 334 your code is throwing index out of range exception.

Kindly modify your code for inputs who length is greater than 2.