I know that ->
is used for lambda expressions with the syntax ()->{}
.
But I saw this code: file -> file.isFile()
- with no ()
and {}
. What does it do?
()
is not required when you have a single argument and {}
is not required when your lambda body is a single expression.
See the Java tutorial for further information and the Java Specification for a more formal description of the syntax.