The idea behind an unBound receiver, such as String::length , is that you reference a method to an object that will be supplied as one of the lambda parameters . For example, a lambda expression (String s) -> s.toUpperCase() can be rewritten as String::toUpperCase .
But Bounded refers to a situation where you call a method in lambda for an external object that already exists . For example, lambda expression () -> expensiveTransaction.getValue() can be rewritten as expensiveTransaction::getValue .
Situations for three different ways to refer to a method
(args) -> ClassName.staticMethod(args) can be ClassName::staticMethod
(arg0, rest) -> arg0.instanceMethod(rest) can be ClassName::instanceMethod ( arg0 is of type ClassName )
(args) -> expr.instanceMethod(args) can be expr::instanceMethod
Answer removed from Java 8 in action book
source share