{"id":172766,"date":"2019-11-08T02:46:00","date_gmt":"2019-11-07T18:46:00","guid":{"rendered":"http:\/\/itteacheritfreelance.hk\/test\/wordpress\/?guid=e9109545542334c6bb6058bcbe6a055c"},"modified":"2019-11-08T02:46:00","modified_gmt":"2019-11-07T18:46:00","slug":"get-started-with-lambda-expressions","status":"publish","type":"post","link":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/2019\/11\/08\/get-started-with-lambda-expressions\/","title":{"rendered":"Get started with lambda expressions"},"content":{"rendered":"<article>\n<section class=\"page\">\n<p>Before Java SE 8, anonymous <a href=\"http:\/\/itteacheritfreelance.hk\/index.php\" title=\"\u672c\u7db1\u9801\u63d0\u4f9b\u4e00\u500b\u65b9\u4fbf\u7684\u5e73\u53f0, \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b , PHP\u88dc\u7fd2, HTML\u88dc\u7fd2, CSS\u88dc\u7fd2, JavaScript\u88dc\u7fd2, XML, Java\u88dc\u7fd2,Server\u88dc\u7fd2, MySQL\u88dc\u7fd2, \u4e2d\u5b78\u96fb\u8166\u79d1\u79c1\u4eba\u88dc\u7fd2, \u5728\u8077\u4eba\u58eb\u96fb\u8166\u63d0\u5347\u88dc\u7fd2,\u5c08\u696d\u8003\u8a66\u96fb\u8166 \u88dc\u7fd2,\u96fb\u8166\u5716\u50cf\u8a2d\u8a08\u96fb\u8166\u88dc\u7fd2, gra\">class<\/a>es were typically used to pass functionality to a method. This practice obfuscated source code, making it harder to understand. Java 8 eliminated this problem by introducing lambdas. This tutorial first introduces the lambda language feature, then provides a more detailed introduction to functional programming with lambda expressions along with target types. You&#8217;ll also learn how lambdas interact with scopes, local variables, the <code>this<\/code> and <code>super<\/code> keywords, and Java exceptions.\u00a0<\/p>\n<p>Note that code examples in this tutorial are compatible with JDK 12.<\/p>\n<aside class=\"sidebar\">\n<h3>Discovering types for yourself<\/h3>\n<p>I won&#8217;t introduce any non-lambda language features in this tutorial that you haven&#8217;t previously learned about, but I will demonstrate lambdas via types that I haven&#8217;t previously discussed in this series. One example is the <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/12\/docs\/api\/java.base\/java\/lang\/Math.html\" rel=\"nofollow\"><code>java.lang.Math<\/code><\/a> <a href=\"http:\/\/itteacheritfreelance.hk\/index.php\" title=\"\u672c\u7db1\u9801\u63d0\u4f9b\u4e00\u500b\u65b9\u4fbf\u7684\u5e73\u53f0, \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b , PHP\u88dc\u7fd2, HTML\u88dc\u7fd2, CSS\u88dc\u7fd2, JavaScript\u88dc\u7fd2, XML, Java\u88dc\u7fd2,Server\u88dc\u7fd2, MySQL\u88dc\u7fd2, \u4e2d\u5b78\u96fb\u8166\u79d1\u79c1\u4eba\u88dc\u7fd2, \u5728\u8077\u4eba\u58eb\u96fb\u8166\u63d0\u5347\u88dc\u7fd2,\u5c08\u696d\u8003\u8a66\u96fb\u8166 \u88dc\u7fd2,\u96fb\u8166\u5716\u50cf\u8a2d\u8a08\u96fb\u8166\u88dc\u7fd2, gra\">class<\/a>. I will introduce these types in future Java 101 tutorials. For now, I suggest reading the <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/12\/docs\/api\/index.html\" rel=\"nofollow\">JDK 12 API documentation<\/a> to learn more about them.<\/p>\n<p class=\"jumpTag\"><a href=\"https:\/\/www.javaworld.com\/article\/3452018\/get-started-with-lambda-expressions.html#jump\">To read this article in full, please click here<\/a><\/p>\n<\/section>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<article>\n<section>\n<p>Before Java SE 8, anonymous classes were typically used to pass functionality to a method. This practice obfuscated source code, making it harder to understand. Java 8 eliminated this problem by introducing lambdas. This tutorial first introduces the lambda language feature, then provides a more detailed introduction to functional programming with lambda expressions along with target types. You&#8217;ll also learn how lambdas interact with scopes, local variables, the <code>this<\/code> and <code>super<\/code> keywords, and Java exceptions.&nbsp;<\/p>\n<p>Note that code examples in this tutorial are compatible with JDK 12.<\/p>\n<aside>\n<h3>Discovering types for yourself<\/h3>\n<p>I won&#8217;t introduce any non-lambda language features in this tutorial that you haven&#8217;t previously learned about, but I will demonstrate lambdas via types that I haven&#8217;t previously discussed in this series. One example is the <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/12\/docs\/api\/java.base\/java\/lang\/Math.html\" rel=\"nofollow\"><code>java.lang.Math<\/code><\/a> class. I will introduce these types in future Java 101 tutorials. For now, I suggest reading the <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/12\/docs\/api\/index.html\" rel=\"nofollow\">JDK 12 API documentation<\/a> to learn more about them.<\/p>\n<p><a href=\"https:\/\/www.javaworld.com\/article\/3452018\/get-started-with-lambda-expressions.html#jump\">To read this article in full, please click here<\/a><\/p>\n<\/aside>\n<\/section>\n<\/article>\n<p> <a href=\"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/2019\/11\/08\/get-started-with-lambda-expressions\/\">\u95b1\u8b80\u5168\u6587 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":123,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"slim_seo":[],"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[451,2,7],"tags":[398,402,397,414,413,410,409,407,408,406,399,400,394,318,558,560,555,561,566,553,554,586,585,563,562,183,567,524,10,401,396,403,412,411,395,405,404,457,454,319,316],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7prtj-IWy","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/posts\/172766"}],"collection":[{"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/users\/123"}],"replies":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/comments?post=172766"}],"version-history":[{"count":2,"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/posts\/172766\/revisions"}],"predecessor-version":[{"id":173638,"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/posts\/172766\/revisions\/173638"}],"wp:attachment":[{"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/media?parent=172766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/categories?post=172766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-json\/wp\/v2\/tags?post=172766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}