About Question enthuware.ocpjp.v8.2.1873 :
Posted: Sun Sep 27, 2020 3:06 pm
Hi Paul!
I have a question about one book that you recommended me: "Java 8 in Action" (Raoul-Gabriel Urma, Mario Fusco, Alan Mycroft).
In the page 83, at the beginning of the page says:
Table 3.4. Examples of lambdas and method reference equivalents
Paul, I am not able to assignate this last method reference to a Functional Interface, I think should be a Supplier interface because doesn´t have any parameters, but the compiler is saying that dumpStack is void, so Supplier doesn´t work here... and I don´t know if the type of the interface should be Thread. I did something like this:
Supplier<Thread> function = Thread.currentThread()::dumpStack; // not compile
Could you help me to assignate correctly this method reference please?
Thank you in advance
I have a question about one book that you recommended me: "Java 8 in Action" (Raoul-Gabriel Urma, Mario Fusco, Alan Mycroft).
In the page 83, at the beginning of the page says:
Table 3.4. Examples of lambdas and method reference equivalents
Code: Select all
() -> Thread.currentThread().dumpStack()
Code: Select all
Thread.currentThread()::dumpStack
Supplier<Thread> function = Thread.currentThread()::dumpStack; // not compile
Could you help me to assignate correctly this method reference please?
Thank you in advance