Is there a way in Java8 to use a method reference as a Function object to use its methods, something like:
Function
Stream.of(\"ciao\", \"hola\", \"hello
You can just save it into a variable:
Function toLength = String::length; Stream.of("ciao", "hola", "hello") .map(toLength.andThen(n -> n * 2));
Or you can use a cast, but it's less readable, IMO:
Stream.of("ciao", "hola", "hello") .map(((Function) String::length).andThen(n -> n * 2));