This bit of code im working on is supposed to print the inputted string in steps minus 1 letter every time.
ex.
BANANA
BANAN
BANA
BAN
BA
B
Here is my code:
Triangle triangle = new Triangle(); //test driver
triangle.triangleLoop("BANANA"); //test driver
public void triangleRecursive(String input){
String recursiveInput = "";
int strLength = input.length();
String[] temp = input.split("");
for(int i=0;i<strLength;i++){
System.out.println(input);
temp[strLength - i] = "";
for(int c=0;c<temp.length;c++){
recursiveInput = recursiveInput + temp[c];
}
triangleRecursive(recursiveInput);
}
}
My code works fine and prints the desired output. However what happens afterwords is a little bit peculiar.
ex.
//desired output here, No Problems! then....
BA
B
BAN
BAB
It prints this pattern infinitely. Ive been trying to fix it but I havent found a way that won't break the part that works. Any help is appreciated.
Cheers,