我试图在我的代码中使用Java 8方法引用.有四种类型的方法参考可用.
随着Static method reference和Constructor reference我有没有问题,但Instance Method (Bound receiver)和Instance Method (UnBound receiver)真搞糊涂了.在Bound接收器中,我们使用Object引用变量来调用方法,如:
objectRef::Instance Method
Run Code Online (Sandbox Code Playgroud)
在UnBound接收器中,我们使用类名来调用方法,如:
ClassName::Instance Method.
Run Code Online (Sandbox Code Playgroud)
我有以下问题:
Bound和Unbound接收方法引用有什么区别?Bound在哪里使用Unbound接收器?我们应该在哪里使我还从Java 8语言特性书中找到了解释Bound和Unbound接收器,但仍然与实际概念混淆.