How to pass argument to class constructor when initialzed thru ::new in Java8

前端 未结 3 770
时光取名叫无心
时光取名叫无心 2021-01-03 00:41

I am using java 8 stream API to perform action on a list of Store objects.

Store takes a String argument and a Mapper

3条回答
  •  春和景丽
    2021-01-03 01:21

    Use a lambda expression instead of a method reference

      .map(name -> new Store(name, mapper))
    

提交回复
热议问题