@tishachhabra2702_8fc5a68a2e295e35 In the basecase when str.length()==0 you have to print the result and return from the function otherwise you will get IndexOutOfBound Exception. So in the base add a return statement. One more thing that you have to do is Your SysO statement is not correct due to two times Double quote. So write like this :
Corrected Code :
import java.util.ArrayList;
public class Main
{
static void printsub(String str,String res)
{
if(str.length()==0){
System.out.print(res+", ");
return;
}
printsub(str.substring(1),res);
printsub(str.substring(1),res+str.charAt(0));
}
public static void main(String[] args)
{
printsub("abc","");
}
}