In Java, we know that two types of data are primitive and object. So, Lambda Expression is defined as an anonymous function, what is its data type? In this tutorial, let’s find out together!
OK, as I mentioned earlier, Lambda Expression is used with a Functional Interface. This means, we can use Lambda Expression wherever its data type is a Functional Interface.
Functional Interface basically has only one abstract method, so we can easily map it to a Lambda Expression to implement that abstract method. During compile and runtime, Java generates an object with a Functional Interface data type that uses the content of Lambda Expression implementation.
But it is important to remember that there is no class and therefore no object is directly related to this Lambda Expression. It is just an instruction for Java to create an object for the Functional Interface.