我试图在我的代码中使用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
接收器,但仍然与实际概念混淆.