Use Method reference

// Think of method references are shorthand expressions
// where argument(s) can be inferred
// General syntax is
// instance::methodName or Type::methodName
// When to use? Whenever you might use a lamdba expression
// just to pass a value through to a method
Instead of:
list.forEach(value -> System.out.println(value))
use:
list.forEach(System.out::println)
If you have a method declared like:
map(Function<T, R> f) {...}
instead of:
map(value -> value.toUpperCase())
use:
map(String::toUpperCase)

Method references

Kind

Example

Reference to a static method

ContainingClass::staticMethodName

Reference to an instance method of a particular object

containingObject::
instanceMethodName

Reference to an instance method of an arbitrary object of a particular type