physicsfun
- 10
- 0
can someone explain java recursion to me?
Last edited:
The discussion focuses on Java recursion, highlighting two main types: functional recursion and type recursion. Functional recursion is exemplified by the factorial function, which demonstrates the need for a base case and a recursive case. The discussion emphasizes that while recursion is a common programming concept, Java's Virtual Machine (JVM) does not efficiently support tail recursion, leading to potential stack overflow issues. This limitation is also present in other JVM languages such as Scala and Clojure.
PREREQUISITESSoftware developers, computer science students, and anyone interested in mastering recursion in Java and understanding its limitations within the JVM context.
class LinkedNode
{
public int data;
public LinkedNode next;
}
int factorial(int n)
{
if(n<=0)
return 1;
else
return n * factorial(n-1);
}