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:

Image Learn the concept of recursion.

Image Write and use recursive methods.

Image Determine the base case and recursion step in a recursive algorithm.

Learn how recursive ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.