Below is a simple interface that my lambda will target.
@FunctionalInterface
interface Converter<F, T> {
T convert(F from);
}
Here is my targeting lambda in the first line of the code below.
Converter<String, Integer> converter = (from) -> Integer.valueOf(from);
Integer converted = converter.convert("123");
System.out.println(converted);
Syntax-wise, I can even further simplify my targetting line like this:
Converter<String, Integer> converter = Integer::valueOf;
My question is about the reference to the static method valueOf() in Integer. (i.e. Integer::valueOf)
Why does its presence work here in place of a lambda? Is it because the lambda is there (hiding) and the lambda is providing a method body for convert() by "borrowing" an existing body from elsewhere (i.e. the Integer class), instead of explicitly defining the body?