declaring an IntConsumer like this:
int z = 0;
IntConsumer iConsumer = (a) -> z;
gives a compilation error: "Void methods cannot return a value". Ok
But like this :
int z = 0;
IntConsumer iConsumer = (a) -> Function.identity().apply(z);
When Function.identity().apply(z)
returns an Object
, no compilation error here.
Shouldn't also give a compilation error?