So, the task is to create a string that makes a progression throughout the letters of a string, returning a substring progressively longer. For example if the input is Book, the answer would be: BBoBooBook . For the input Soup the method would return SSoSouSoup. I want to write it recursively. In my current method I receive no error but at the same time no anwer from the compiler.
public static String stringProgression(String str) {
int index = 1;
String result = "";
if (str.length() == 0) {
return "" ;
} else while (index <= str.length()); {
result = result + stringExplosion(str.substring(0, index));
index++;
}
return result;
}
stringExplosion?while (index <= str.length());is probably a typo. Ifindex<str.length(), that becomeswhile(true);so the loop never ends.