This site was easy to understand https://employment.en-japan.com/engineerhub/entry/2019/04/25/103000
I couldn't understand that the lambda expression was included in the argument of the sort method of the list without the variable declaration, so I checked it.
It's normal to use a lambda expression instead of overriding a method in an anonymous class, but I was somewhat convinced by the explanation.
Quoted from the above site
new Predicate<Integer>() {
@Override
public boolean test(Integer number) {
return Math.abs(number) >= 5;
}
}
And this process can be replaced with a lambda expression, which can be written as the following code:
number -> Math.abs(number) >= 5
Recommended Posts