previous |
start |
next
Recursion
- A recursive computation solves a problem by using the solution
of the same problem with simpler input.
- For recursion to terminate, there must be special cases for the
simplest inputs.
- To complete our Triangle example, we must handle width <=
0
- add this line to the getArea method
if (width <= 0) return 0;
previous |
start |
next