Java 8 Supplier with arguments in the constructor

后端 未结 8 1989
小蘑菇
小蘑菇 2020-12-01 00:07

Why do suppliers only support no-arg constructors?

If the default constructor is present, I can do this:

create(Foo::new)

But if th

8条回答
  •  情书的邮戳
    2020-12-01 00:27

    That's just a limitation of the method reference syntax -- that you can't pass in any of the arguments. It's just how the syntax works.

提交回复
热议问题