英文来源于:Java in a Nutshell, 6th Edition
Definition of a Lambda Expression
A lambda expression is essentially a function that does not have a name, and can be
treated as a value in the language. As Java does not allow code to run around on its
own outside of classes, in Java, this means that a lambda is an anonymous method
that is defined on some class (that is possibly unknown to the developer).
—Java in a Nutshell, 6th Edition
其实正则表达式就是没有名字的函数,(参数,返回值,函数体),在java 语言中视为一个值.
因为java的函数必须在类中定义,这就意味着,java语言中的函数表达式即为在某类中定义的匿名方法.
函数表达式在java视为一个值,即:Runnable r = () -> System.out.println(“Hello World”); 形式.
时间: 2024-11-03 03:25:23