Java Reference
In-Depth Information
18
Recursion
O! thou hast damnable
iteration, and art indeed able to
corrupt a saint.
—William Shakespeare
It's a poor sort of memory that
only works backwards.
—Lewis Carroll
Life can only be understood
backwards; but it must be lived
forwards.
—Soren Kierkegaard
Objectives
In this chapter you'll:
Learn the concept of
recursion.
■
Write and use recursive
methods.
■
Determine the base case and
recursion step in a recursive
algorithm.
■
Learn how recursive method
calls are handled by the
system.
■
Learn the differences between
recursion and iteration, and
when to use each.
■
Learn what fractals are and
how to draw them using
recursion.
■
Learn what recursive
backtracking is and why it's
an effective problem-solving
technique.
■