문제

May I say that?

Anonymous class looks like OO style while lambda expression makes it functional style.

도움이 되었습니까?

해결책

Are you asking about lambdas in Java 8?

A Java 8 lambda is a simplification for a subset of anonymous classes -- namely, anonymous classes that extends a "functional interface", and has exactly one method, does not use this, does not use initializer blocks, and has no fields. (However, this is a very common use case for anonymous classes.)

In other words, any lambda expression can be re-written into an equivalent anonymous class creation expression. But only some (not all) anonymous class creation expressions can be re-written into a lambda expression.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top