Java8 method reference used as Function object to combine functions

前端 未结 7 1581
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 15:02

Is there a way in Java8 to use a method reference as a Function object to use its methods, something like:

Stream.of(\"ciao\", \"hola\", \"hello         


        
7条回答
  •  囚心锁ツ
    2020-12-14 15:40

    You could write:

    Stream.of("ciao", "hola", "hello").map(String::length).map(n -> n * 2);
    

提交回复
热议问题