Lambda Function in Java
Lambda expression replaces anonymous classes and removes all boiler plate, enabling you to write code in functional style, which is some time more readable and expression.
Lambda Expression vs Anonymous class
- Keyword this. For anonymous class this keyword resolves to anonymous class, whereas for lambda expression this keyword resolves to enclosing class where lambda is written.
- The compiled way. Java compiler compiles lambda expressions and convert them into private method of the class.