What is problem in this code second test are wrong

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 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 ArrayList<String> letterCombinations(String digits) {
	    if (digits.length() != 0)
	      backtrack("", digits);
	    return output;
	  }
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
for(String a:letterCombinations(str)) {
	System.out.println(a);
}
}

}

@sksumitkumardiwaker,
your code is not working if the length of input is greater than 2.

Eg. 560

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.