ERROR - "Lambda expression's signature does not match the signature of the functional interface method get()" while using Supplier and Lambda Expressions in Java 8

Error

Lambda expression's signature does not match the signature of the functional interface method get()

while using Supplier and Lambda Expressions in Java 8.

Error Type


Compile Time ( Java 8 )


Sample Code


Supplier spr = p->p;

Cause


Supplier represent a function that accepts no argument and produces result of any type. We shouldn't specify the anonymous argument p here.

Resolution

Specify the Supplier correctly. 


Supplier spr = HelloJava8::New;