Chapter 10. Recursive Data

If somebody there chanced to be

Who loved me in a manner true

My heart would point him out to me

And I would point him out to you.

—Gilbert and Sullivan, Ruddigore, 1887

One of the important strengths of modern programming languages lies in the flexibility they offer for data representation. Early languages, such as FORTRAN, restricted the user to a small set of primitive data types and arrays. Java programmers have considerably more freedom because the language allows them to define new classes to represent more sophisticated structures. These classes, moreover, can be recursive in that the definition of a class can include references to objects of the same class. Recursive classes of this sort make it possible to apply the power of recursion to data representation in much the same way that recursive methods provide a powerful tool for defining the algorithmic structure of a program.

Get Thinking Recursively with Java 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.