java8函数表达式的定义[Definition of a Lambda Expression]

馋奶兔 提交于 2019-12-05 08:18:14

英文来源于: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"); 形式.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!