Tuesday, June 26, 2018

Lambda expression performance


https://stackoverflow.com/questions/22637900/java8-lambdas-vs-anonymous-classes

An anonymous inner class (AIC) is a class, which means that it has scope for variable defined inside the inner class.
Whereas,lambda expression is not a scope of its own, but is part of the enclosing scope.
 At runtime anonymous inner classes (AIC) require class loading, memory allocation and object initialization and invocation of a non-static method while lambda expression is pure compile time activity and don’t incur extra cost during runtime. So performance of lambda expression is better as compare to anonymous inner classes.**

No comments: