Java lambda returning a lambda

前端 未结 4 858
借酒劲吻你
借酒劲吻你 2020-11-27 06:01

I am trying to do what seems to be a relatively basic thing in the new JDK 8 land of functional programming, but I can\'t get it to work. I have this working code:

4条回答
  •  爱一瞬间的悲伤
    2020-11-27 06:33

    I ran into this same issue and was able to solve it by explicitly specifying the generic type-parameter to map like so:

    List> checks = l.stream().
       >map(n -> () -> {
          System.out.println(n); 
          return null;
       }).
       collect(Collectors.toList());
    

提交回复
热议问题