September 2019
Intermediate to advanced
816 pages
18h 47m
English
In this solution, we will highlight the purpose and usability of a functional interface in comparison with several alternatives. We will look at how to evolve the code from its basic and rigid implementation to a flexible implementation based on a functional interface. For this, let's consider the following Melon class:
public class Melon { private final String type; private final int weight; private final String origin; public Melon(String type, int weight, String origin) { this.type = type; this.weight = weight; this.origin = origin; } // getters, toString(), and so on omitted for brevity}
Let's assume that we have a client – let's call him Mark – who wants to start up a melon-selling business. We shaped ...