+ 1
program of infinite recursion
4 Antworten
+ 17
static void recInf (){System.out.println("hahaha"; recInf ();}
+ 7
Is this what you mean? :
void recursiveMethod( ) {
while(true) {
recursiveMethod( );
}
}
+ 7
More like,
void infiniteRecursion() {
infiniteRecursion();
}
we do not need while(true)
+ 1
"infinite" is a very loose term here, as you will quickly get a stack overflow exception. It's often better performance wise to store results in your own stack object, and will avoid stack overflow exceptions.
https://code.sololearn.com/c64r9v4oILze/#