Item 43: Prefer method references to lambdas

Introduction Method references are more concise than lambdas. If method references are shorter and clearer, use them; otherwise, utilize lambdas. Method references reduce the boilerplate code and thus improves readability. There are four kinds of method references, which are summarized below: Kind Example Reference to a static method ContainingClass::staticMethodName Reference to an instance method of […]

Item 44: Favor the use of standard functional interfaces

If one of the standard functional interfaces does the job, you should generally use it in preference to a purpose-built functional interface This will make your API easier to learn, by reducing its conceptual surface area, and will provide significant interoperability benefits Always annotate your functional interfaces with the @FunctionalInterface annotation @FunctionalInterface annotation is used […]