A quick review of Java features from 11 to 17+
This version update presents performance and optimization improvements. In this section, we will examine those that are very useful for the specific use of a design pattern and its structure. This equates to platform enhancements that improve code readability, platform usage, or syntax enhancements.
The local variable syntax for lambda parameters (Java SE 11, JEP-323)
Java has often been criticized for the amount of standard code in the use of a variable; Java SE 10 introduced a new keyword, var
. The derivation of a local type variable lies behind this keyword. It essentially requires that the value type is taken from the newly created reference instance (Example 2.20). Using the stream boxed
function shows a decorator pattern that wraps the stream value with the desired type:
Consumer<Integer> consumer = (var number) -> { var result = number + 1; System.out.println("...