When i run this function, I am getting Stackoverflow exception.I am not able to find the reason. I am getting exception where i am calling recursive function.
public static ArrayList getBoardPath(int start,int end) {
if(start > end){
ArrayList<String> baseResult = new ArrayList<>();
return baseResult;
}
if(start == end){
ArrayList<String> baseResult = new ArrayList<>();
baseResult.add("");
return baseResult;
}
ArrayList<String> currentResult = new ArrayList<>();
for(int dice=0; dice<=6; ++dice) {
ArrayList<String> recResult = getBoardPath(start+dice,end);
for( String oneOfTheCombination : recResult ){
currentResult.add(dice + oneOfTheCombination);
}
}
return currentResult;
}