So I've been "studying" java for two semesters, and my teacher is not what you would call the best. I was just wondering if any of you guys could help me out with some questions I have...
What is a recursive termination condition and what happens if a recursive function does not contain this condition?

A recursive termination condition is generally called a 'base case' I think. So go look up 'recursion base case' on google. I've never even heard it called a recursive termination condition before. And a base case is necessary because without one, your method will keep recursively calling itself, and will have no mechanism to stop. For more info - use google. :)

recursive termination condition is also called a stopping state...so im guessing your right?
without a stopping state, it would just keep calling itself right?

recursive termination condition is also called a stopping state...so im guessing your right?
without a stopping state, it would just keep calling itself right?

Yes. The stopping state is called a 'base case', and there can be more than one. And yes, without a base case, it would keep calling itself, leading to a stack overflow as noodle says. In java it would just throw a StackOverflowException. But in any programming language, the concept is the same. Simple example (you'd never code anything like this, but just as an example):

public void myMethod(int current){
if (current <= 0) return;
current--;
myMethod(current);
}

Now consider what would happen if the base case (the first line of code in the method) was taken away. It would never stop calling itself.

This article has been dead for over six months. Start a new discussion instead.