17.2 Functional Programming Technologies Overview

In the preceding chapters, you learned various procedural, object-oriented and generic programming techniques. Though you often used Java library classes and interfaces to perform various tasks, you typically determine what you want to accomplish in a task then specify precisely how to accomplish it. For example, let’s assume that what you’d like to accomplish is to sum the elements of an array named values (the data source). You might use the following code:

int sum = 0;for (int counter = 0; counter < values.length; counter++)   sum += values[counter];

This loop specifies how we’d like to add each array element’s value to the sum—with a for repetition statement ...

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.