About Question enthuware.ocpjp.v8.2.1885 :
Posted: Mon Sep 14, 2020 1:42 pm
Hi Paul!
I don´t understand why in some cases the Consumer function ignores the return type returned from the function and in other cases not.
Paul could you explain me why is this behaviour, in one is ignoring the return type and in the other one not???
Thank you in advance
I don´t understand why in some cases the Consumer function ignores the return type returned from the function and in other cases not.
Code: Select all
Consumer<Book> c = b->b.getId()+":"+b.getTitle();// this doesn´t compile, the type of the expression must be void, here is a String.
Code: Select all
Consumer<Book> c = b->b.getTitle();// but here compiles, the type of the expression is String as the previous one.
Thank you in advance