Lambda Expression and generic defined only in method

You can’t use a lambda expression for a functional interface, if the method in the functional interface has type parameters. See section §15.27.3 in JLS8:

A lambda expression is compatible [..] with a target type T if T is a functional interface type (§9.8) and the expression is congruent with the function type of [..] T. [..] A lambda expression is congruent with a function type if all of the following are
true:

  • The function type has no type parameters.
  • [..]

Leave a Comment