I am trying to use Java 8 method references in my code. There are four types of method references available.
- Static method reference.
- Instance Method (Bound receiver).
- Instance Method (UnBound receiver).
- Constructor reference.
With Static method reference and Constructor reference i have no problem, but Instance Method (Bound receiver) and Instance Method (UnBound receiver) really confused me. In Bound receiver, we are using an Object reference variable for calling a method like:
objectRef::Instance Method
In UnBound receiver we are using Class name for calling a method like:
ClassName::Instance Method.
I have the following question:
- What is the need for different types of method references for Instance Methods?
- What is the difference between
BoundandUnboundreceiver method references? - Where should we use
Boundreceiver and where should we useUnboundreceiver?
I also found the explanation of Bound and Unbound receiver from Java 8 language features books, but was still confused with the actual concept.
