In this article, 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:
Java
x
12
1
public class Melon {
2
3
private final String type;
4
private final int weight;
5
private final String origin;
6
7
public Melon(String type, int weight, String origin) {
8
this.type = type;
9
this.weight = weight;
10
this.origin = origin;
11
}
12
13
// getters, toString(), and so on omitted for brevity
14
}
from DZone.com Feed https://ift.tt/2TvZBIp
No comments:
Post a Comment