O'Reilly logo

Functional Programming in Java: How functional techniques improve your Java programs by Pierre-Yves Saumont

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Working with laziness

This chapter covers

  • Understanding the importance of laziness
  • Implementing laziness in Java
  • Creating a lazy list data structure: the Stream
  • Optimizing lazy lists by memoizing evaluated values
  • Handling infinite streams

Some languages are said to be lazy, while others are not. Does this mean that some languages work harder than others? Not at all. Laziness is opposed to strictness. It has nothing to do with how hard a language can work, although you could sometimes think of lazy languages as languages that don’t require the programmer to work as hard as they must with strict ones.

Laziness, as you’ll see, has many advantages for some specific problems, such as composing infinite data structures and evaluating ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required