As rogue mentions, your block:
else //recursive case
combos(counter + "A");
combos(counter + "B");
combos(counter + "C");
... will only execute combos(counter + "A");
contextually to the else
statement.
The following recursive statements ("B" and "C") will be executed regardless of your if
condition.
This is likely to cause a fault in your flow control, hence your StackOverflowError
.
Add brackets to enclose your else
statement:
else {//recursive case
combos(counter + "A");
combos(counter + "B");
combos(counter + "C");
}