I have just started to go through 'Java. The Complete Reference' book 9th edition (JDK 8).
On chapter 15 p. 397 started learning 'Method References to Instance Methods' & played around. All examples in book make sense & works, but, I have trouble to understand why would following code works:
Whilst following method isn't:
I know, that failing code is using class to get instance method, not instance itself. However, as per book, this code works (using generics, but still I think similar functionality):
Compiler of failing java code gives result:
$ javac -Xdiags:verbose -d bin src/book/lambda/MethodReferenceInstance.java
src\book\lambda\MethodReferenceInstance.java:27: error: method stringOps in class MethodReferenceInstance cannot be applied to given types;
reason: argument mismatch; invalid method reference
cannot find symbol
symbol: method strReverse(String)
location: class MyStringOps
I was trying to find out regarding this compiler error, but it's not that easy... Wondering, would someone in simple terms could explain why above code is failing?