+ 1

program of infinite recursion

3rd Feb 2018, 6:58 PM
Bikram Bhullar
Bikram Bhullar - avatar
4 Réponses
+ 17
static void recInf (){System.out.println("hahaha"; recInf ();}
4th Feb 2018, 4:50 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 7
Is this what you mean? : void recursiveMethod( ) { while(true) { recursiveMethod( ); } }
3rd Feb 2018, 7:00 PM
Fabio
+ 7
More like, void infiniteRecursion() { infiniteRecursion(); } we do not need while(true)
3rd Feb 2018, 7:27 PM
Saminjay Goel
Saminjay Goel - avatar
+ 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/#
4th Feb 2018, 3:50 AM
Jesse Bayliss
Jesse Bayliss - avatar