Aguid
Aguid

Reputation: 1043

Why Java Lambda Type Inference deals only with method with unique parameter ?

If the compiler can figure out the type of the method with only one parameter, why it is not able to do the same for methods with two parameters or more tacking acount the order of parameters ?

Here an example :

enter image description here

In another way, Why the compile can't figure out that str is a String (First parameter in the unique method, and also str2 is a String (second parameter in the unique method) ?

Upvotes: 2

Views: 105

Answers (1)

Eugene
Eugene

Reputation: 120978

It seems you are not defining this correctly:

(str, str2) -> str.length()

You should also receive a compile time error for the second example.

Upvotes: 4

Related Questions