15. Recursion

We must learn to explore all the options and possibilities that confront us in a complex and rapidly changing world.

James William Fulbright

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

Push on—keep moving.

Thomas Morton

Objectives

In this chapter you will learn:

  • The concept of recursion.

  • How to write and use recursive methods.

  • How to determine the base case and recursion step in a recursive algorithm.

  • How recursive method ...

Get Java™ How to Program, Seventh 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.