﻿{"id":693,"date":"2013-04-09T11:10:10","date_gmt":"2013-04-09T02:10:10","guid":{"rendered":"http:\/\/yucchi.jp\/blog\/?p=693"},"modified":"2013-04-24T19:43:31","modified_gmt":"2013-04-24T10:43:31","slug":"jdk8-lambda-%e3%81%9d%e3%81%ae%e4%bb%96%e3%81%84%e3%82%8d%e3%81%84%e3%82%8d-%e3%81%aa%e3%82%93%e3%81%a7%e3%82%82%e3%81%84%e3%81%84%e3%81%8b%e3%82%89%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6%e3%81%bf-7","status":"publish","type":"post","link":"http:\/\/yucchi.jp\/blog\/?p=693","title":{"rendered":"JDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b \u305d\u306e\uff18"},"content":{"rendered":"<p>\u4eca\u65e5\u3082\u300cJDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b\u300d\u30b7\u30ea\u30fc\u30ba\u3067 GO! GO! GO! \u3060\u305c\u3047\uff5e<\/p>\n<p>\u30ef\u30a4\u30eb\u30c9\u3060\u308d\u3045\uff08\u3082\u3046\u53e4\u3044\uff09<\/p>\n<p>\u4eca\u56de\u306f\u3001\u58f2\u8cb7\u4fa1\u683c\u306b\u3088\u308b\u30bd\u30fc\u30c8\u3092\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u4eca\u307e\u3067\u306e\u77e5\u8b58\u3092\u4f7f\u3048\u3070\u7c21\u5358\u306b\u5b9f\u88c5\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u30b5\u30e9\u30c3\u3068\u6d41\u3057\u307e\u3057\u3087\u3046\u3002(^_^;<\/p>\n<p>\u3067\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30b3\u30fc\u30c9\u306f\u4e0b\u8a18\u306e\u3088\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<style type=\"text\/css\">\n<!--\ntable {color: #000000; background-color: #e9e8e2; font-family: \u3086\u305f\u307d\u3093\uff08\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\uff09}\n-->\n<\/style>\n<table width=\"100%\">\n<tbody>\n<tr>\n<td align=\"left\">mylambdaexamples\\MyLambdaExamples.java<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre start-line=\"98\">\r\n\/\/ \u58f2\u8cb7\u4fa1\u683c\u306b\u3088\u308b\u30bd\u30fc\u30c8\r\nSystem.out.println(\"\\n<-- \u58f2\u8cb7\u4fa1\u683c\u306b\u3088\u308b\u30bd\u30fc\u30c8 -->\");\r\nComparator<Sale> byCost = comparing((ToDoubleFunction<Sale>) Sale::getCost);\r\nsales.sorted(byCost)\r\n        .collect(toList())\r\n        .forEach(s -> {System.out.println((int)s.getCost() \r\n                + \" : \" + s.wristwatch.getBrand()\r\n                + \" : \" + s.wristwatch.getModel()\r\n                + \"   \"\r\n                + s.seller.getFirstName() + \" \"\r\n                + s.seller.getLastName()\r\n                + \" -----> \"\r\n                + s.buyer.getFirstName() + \" \"\r\n                + s.buyer.getLastName());});\r\n\r\n<\/pre>\n<p>\u3068\u3066\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u30b3\u30fc\u30c9\u3067\u3059\u3063\u304d\u308a\u3057\u3066\u307e\u3059\u306d\u3002<\/p>\n<p>\u8cfc\u5165\u4fa1\u683c\u3092\u30bd\u30fc\u30c8\u3057\u3066\u3001\u305d\u308c\u3092\u30d9\u30fc\u30b9\u306b sales \u30b9\u30c8\u30ea\u30fc\u30e0\u3092\u30bd\u30fc\u30c8\u3059\u308b\u306e\u306b sorted() \u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u306b\u6e21\u3057\u3001\u30ea\u30b9\u30c8\u3092 collect(toList) \u30e1\u30bd\u30c3\u30c9\u3067\u518d\u69cb\u7bc9\u3057\u3066 forEach() \u30e1\u30bd\u30c3\u30c9\u3067\u8868\u793a\u3055\u305b\u308b\u3002<\/p>\n<p>\u307e\u308b\u3067\u6625\u306e\u5c0f\u5ddd\u306e\u3088\u3046\u306b\u7dba\u9e97\u3067\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u5b9f\u884c\u7d50\u679c\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;&#8211; \u58f2\u8cb7\u4fa1\u683c\u306b\u3088\u308b\u30bd\u30fc\u30c8 &#8211;&gt;<br \/>200000 : \u30ab\u30eb\u30c6\u30a3\u30a8 : \u30de\u30b9\u30c8\u30bf\u30f3\u30af&nbsp;&nbsp; \u5317\u5ddd \u666f\u5b50 &#8212;&#8211;&gt; \u6df1\u7530 \u606d\u5b50<br \/>250000 : \u30ab\u30eb\u30c6\u30a3\u30a8 : \u30de\u30b9\u30c8\u30bf\u30f3\u30af&nbsp;&nbsp; \u7dbe\u702c \u306f\u308b\u304b &#8212;&#8211;&gt; \u5317\u5ddd \u666f\u5b50<br \/>300000 : \u30aa\u30e1\u30ac : \u30c0\u30a4\u30ca\u30df\u30c3\u30af\u30c7\u30d3\u30eb&nbsp;&nbsp; \u5c0f\u6817 \u65ec &#8212;&#8211;&gt; \u5800\u5317 \u771f\u5e0c<br \/>300000 : \u30ed\u30ec\u30c3\u30af\u30b9 : \u30d7\u30ec\u30b7\u30b8\u30e7\u30f3&nbsp;&nbsp; \u7dbe\u702c \u306f\u308b\u304b &#8212;&#8211;&gt; \u6df1\u7530 \u606d\u5b50<br \/>300000 : \u30aa\u30e1\u30ac : \u30c0\u30a4\u30ca\u30df\u30c3\u30af\u30c7\u30d3\u30eb&nbsp;&nbsp; \u7dbe\u702c \u306f\u308b\u304b &#8212;&#8211;&gt; \u6b66\u4e95 \u54b2<br \/>330000 : \u30c1\u30e5\u30fc\u30c9\u30eb : \u30ab\u30e1\u30ec\u30aa\u30f3&nbsp;&nbsp; \u525b\u529b \u5f69\u82bd &#8212;&#8211;&gt; \u4f50\u3005\u6728 \u5e0c<br \/>400000 : \u30ed\u30ec\u30c3\u30af\u30b9 : \u30d7\u30ec\u30b7\u30b8\u30e7\u30f3&nbsp;&nbsp; \u58c7 \u871c &#8212;&#8211;&gt; \u67f4\u7530 \u606d\u5e73<br \/>400000 : \u30c1\u30e5\u30fc\u30c9\u30eb : \u30ab\u30e1\u30ec\u30aa\u30f3&nbsp;&nbsp; \u6df1\u7530 \u606d\u5b50 &#8212;&#8211;&gt; \u7dbe\u702c \u306f\u308b\u304b<br \/>800000 : \u30c6\u30a3\u30d5\u30a1\u30cb\u30fc : \u30dd\u30fc\u30bb\u30ea\u30f3&nbsp;&nbsp; \u7dbe\u702c \u306f\u308b\u304b &#8212;&#8211;&gt; \u6df1\u7530 \u606d\u5b50<br \/>900000 : \u30c6\u30a3\u30d5\u30a1\u30cb\u30fc : \u30dd\u30fc\u30bb\u30ea\u30f3&nbsp;&nbsp; \u6b66\u4e95 \u54b2 &#8212;&#8211;&gt; \u6df1\u7530 \u606d\u5b50<br \/>1000000 : \u30c6\u30a3\u30d5\u30a1\u30cb\u30fc : \u30dd\u30fc\u30bb\u30ea\u30f3&nbsp;&nbsp; \u5e02\u539f \u96bc\u4eba &#8212;&#8211;&gt; \u6df1\u7530 \u606d\u5b50<\/p>\n<p>\u3061\u3083\u3093\u3068\u30bd\u30fc\u30c8\u3055\u308c\u3066\u307e\u3059\u306d\u3002(*^\u25bd^*)<\/p>\n<p>\u3067\u3082 300000 \u5186\u306e\u540c\u3058\u4fa1\u683c\u306e\u30bd\u30fc\u30c8\u306e\u9806\u756a\u306f\u3069\u3046\u306a\u3063\u3066\u308b\u3093\uff1f<\/p>\n<p>\u3061\u3087\u3063\u3068\u6c17\u306b\u306a\u308b\u3051\u3069\u4eca\u306f\u304d\u306b\u3057\u306a\u3044\u3002\uff08\u30f2\u30d2<\/p>\n<p>\u305d\u308c\u3063\u3066\u89e3\u3089\u306a\u3044\u3063\u3066\u7ffb\u8a33\u3059\u308c\u3070\u3044\u3044\u3093\u3060\u308d\uff01<\/p>\n<p>\u305f\u3076\u3093\u3001sales (LinkedHashSet) \u306b\u8ffd\u52a0\u3055\u308c\u305f\u9806\u756a\u304b\u306a\u3002<\/p>\n<p>\u4eca\u65e5\u306f\u7c21\u5358\u3067\u3057\u305f\u306d\uff01<\/p>\n<p>\u305d\u308c\u3067\u306f\u304a\u7d04\u675f\u4e8b\u9805\u3092<\/p>\n<p>\u3053\u306e\u300cJDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b\u300d\u30b7\u30ea\u30fc\u30ba\u306f\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u3067\u5f97\u305f\u60c5\u5831\u3092\u5143\u306b\u305d\u308c\u3092\u5c11\u3057\u5909\u66f4\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002 <\/p>\n<p>\u60b2\u3057\u3044\u3053\u3068\u306b\u305d\u306e\u60c5\u5831\u6e90\u306f\u82f1\u8a9e\u306a\u306e\u3067\u8a73\u3057\u3044\u5185\u5bb9\u306f\u308f\u304b\u308a\u307e\u305b\u3093\u3002 <\/p>\n<p>\u3088\u3063\u3066\u79c1\u306e\u63a8\u6e2c\u3067\u89e3\u91c8\u3055\u308c\u305f\u5185\u5bb9\u3068\u306a\u3063\u3066\u307e\u3059\u306e\u3067\u9593\u9055\u3044\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002 <\/p>\n<p>Java8 \u3082\u307e\u3060 build83 \u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u306e\u3067 API \u306e\u5909\u66f4\u306b\u3088\u308a\u8a18\u8ff0\u65b9\u6cd5\u304c\u5909\u308f\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002 <\/p>\n<p>\u65e9\u304f\u6b63\u5f0f\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3066\u65e5\u672c\u8a9e\u3067\u3053\u306e\u8d85\u4fbf\u5229\u3067\u7d20\u6575\u306a\u65b0\u6a5f\u80fd\u3092\u52c9\u5f37\u3057\u305f\u3044\u4eca\u65e5\u3053\u306e\u9803\u3067\u3059\u3002 <\/p>\n<p>&nbsp;<\/p>\n<div id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4f812252-5db6-475b-8c35-af80e65e6db3\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">Hatena \u30bf\u30b0: <a href=\"http:\/\/b.hatena.ne.jp\/t\/Java\" rel=\"tag\">Java<\/a><\/div>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D693&title=JDK8%20Lambda%20%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%84%E3%82%8D%E3%81%84%E3%82%8D%20%E3%81%AA%E3%82%93%E3%81%A7%E3%82%82%E3%81%84%E3%81%84%E3%81%8B%E3%82%89%E5%8B%95%E3%81%8B%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B%20%E3%81%9D%E3%81%AE%EF%BC%98' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D693&t=JDK8%20Lambda%20%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%84%E3%82%8D%E3%81%84%E3%82%8D%20%E3%81%AA%E3%82%93%E3%81%A7%E3%82%82%E3%81%84%E3%81%84%E3%81%8B%E3%82%89%E5%8B%95%E3%81%8B%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B%20%E3%81%9D%E3%81%AE%EF%BC%98' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"http:\/\/yucchi.jp\/blog\/?p=693\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"http:\/\/yucchi.jp\/blog\/?p=693\" data-text=\"JDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b \u305d\u306e\uff18\" data-lang=\"ja\">Tweet<\/a><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u3082\u300cJDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b\u300d\u30b7\u30ea\u30fc\u30ba\u3067 GO! GO! GO! \u3060\u305c\u3047\uff5e \u30ef\u30a4\u30eb\u30c9\u3060\u308d\u3045\uff08\u3082\u3046\u53e4\u3044\uff09 \u4eca\u56de\u306f\u3001\u58f2\u8cb7\u4fa1\u683c\u306b\u3088\u308b\u30bd\u30fc\u30c8\u3092\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u4eca\u307e\u3067\u306e\u77e5\u8b58\u3092\u4f7f\u3048\u3070\u7c21\u5358\u306b\u5b9f\u88c5\u53ef\u80fd\u3067\u3059\u3002 \u3068\u3044\u3046\u3053\u3068\u3067\u30b5\u30e9\u30c3\u3068\u6d41\u3057\u307e\u3057\u3087\u3046\u3002(^_^; \u3067\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30b3\u30fc\u30c9\u306f\u4e0b\u8a18\u306e\u3088\u306b\u306a\u308a\u307e\u3059\u3002 mylambdaexamples\\MyLambdaExamples.java \/\/ \u58f2\u8cb7\u4fa1\u683c\u306b\u3088\u308b\u30bd\u30fc\u30c8 System.out.println(&#8220;\\n&#8221;); Comparator byCost = comparing((ToDoubleFunction) Sale:\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[17],"class_list":["post-693","post","type-post","status-publish","format-standard","hentry","category-java","tag-java"],"_links":{"self":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=693"}],"version-history":[{"count":2,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/693\/revisions"}],"predecessor-version":[{"id":782,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/693\/revisions\/782"}],"wp:attachment":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=693"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}