Lambdas
In other languages like Python and JavaScript, a function can exist without a class. In Java though, everything must be a class. The only way to do this in Java is with anonymous classes.
In other languages, functions are passed as arguments to other functions. The function object lets us do the same.
Whenever you see lambdas, anonymous classes, or method references, this is what Java tries to copy.
Anonymous Classes
Anonymous classes were the first way to create function objects. But they were too verbose. They also allow many methods. That defeats the point of a function object. A function object should hold just one function, like in other languages.
An anonymous class is a function object when it implements just one method. With more than one method, it's a regular object.
Method Reference
It's more syntactic sugar over lambdas. It refers to an existing method. The function being passed has just one line. That line calls another existing method.
Compile Time and Runtime
At compile time, no class is generated for lambdas. That's unlike anonymous classes. Instead, each function object gets a private method and a bootstrap method in the class. The LambdaMetafactory then builds the instance at runtime.
