
There can be more than
one base case.Failing to
take into account all base
cases can result in a Stack-
OverflowError at run time.
COMMON ERROR
TRAP
13.4 Programming Activity 1: Checking for a Palindrome 961
that is,
n! / ( ( n – p )! * p! ) = ( n – 1 )! / ( ( n – p )! * ( p – 1 )! )
+ ( n – 1 )! / ( ( n – 1 – p )! * p! )
What happens if we code for only one base case when there are two or more
base cases?
When the method is called, the recursive calls will continue to be made,
because the missing base cases will never be detected. This will eventually
generate a StackOverflowError.
13.4 Programming Activity 1: Checking for a Palindrome
In this activity,