{"id":6688,"date":"2022-07-28T13:43:41","date_gmt":"2022-07-28T05:43:41","guid":{"rendered":"http:\/\/123.57.164.21\/?p=6688"},"modified":"2023-11-08T13:23:28","modified_gmt":"2023-11-08T05:23:28","slug":"%e6%b5%85%e8%b0%88%e5%af%b9java%e5%8f%8c%e5%86%92%e5%8f%b7%e7%9a%84%e7%90%86%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=6688","title":{"rendered":"\u6d45\u8c08\u5bf9Java\u53cc\u5192\u53f7::\u7684\u7406\u89e3"},"content":{"rendered":"\n<p><strong>\u53cc\u5192\u53f7\u201c::\u201d\u5c31\u662f Java \u4e2d\u7684\u65b9\u6cd5\u5f15\u7528(Method references)<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u65b9\u6cd5\u5f15\u7528\u7684\u683c\u5f0f\u662f<code>\u7c7b\u540d::\u65b9\u6cd5\u540d<\/code>\u3002\u4e00\u822c\u662f\u7528\u4f5cLambda\u8868\u8fbe\u5f0f\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u65b9\u6cd5\u5f15\u7528\uff0c\u53ef\u4ee5\u5c06\u65b9\u6cd5\u7684\u5f15\u7528\u8d4b\u503c\u7ed9\u4e00\u4e2a\u53d8\u91cf,\u901a\u8fc7\u8d4b\u503c\u7ed9Function\uff0c\u8bf4\u660e\u65b9\u6cd5\u5f15\u7528\u4e5f\u662f\u4e00\u79cd\u51fd\u6570\u5f0f\u63a5\u53e3\u7684\u4e66\u5199\u65b9\u5f0f\uff0cLambda\u8868\u8fbe\u5f0f\u4e5f\u662f\u4e00\u79cd\u51fd\u6570\u5f0f\u63a5\u53e3\uff0cLambda\u8868\u8fbe\u5f0f\u4e00\u822c\u7528\u4e8e\u81ea\u5df1\u63d0\u4f9b\u65b9\u6cd5\u4f53\uff0c\u800c\u65b9\u6cd5\u5f15\u7528\u4e00\u822c\u76f4\u63a5\u5f15\u7528\u73b0\u6210\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>java8\u5141\u8bb8\u6211\u4eec\u4f7f\u7528lambda\u8868\u8fbe\u5f0f\u521b\u5efa\u533f\u540d\u65b9\u6cd5\u3002\u4f46\u6709\u65f6lambda\u8868\u8fbe\u5f0f\u9664\u4e86\u8c03\u7528\u73b0\u6709\u65b9\u6cd5\u4e4b\u5916\u4ec0\u4e48\u4e5f\u4e0d\u505a\u3002\u5728\u8fd9\u4e9b\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7\u540d\u79f0\u5f15\u7528\u73b0\u6709\u7684\u65b9\u6cd5\uff0c\u901a\u5e38\u80fd\u66f4\u76f4\u767d\u7684\u8868\u73b0\u51fa\u65b9\u6cd5\u7684\u8c03\u7528\u8fc7\u7a0b\u3002\u5bf9\u4e8e\u5df2\u7ecf\u5b58\u5728\u7684\u4e14\u5177\u6709\u65b9\u6cd5\u540d\u79f0\u7684\u65b9\u6cd5\uff0c\u5b83\u5176\u5b9e\u662f\u7b80\u6d01\u4e14\u6613\u4e8e\u8bfb\u53d6\u7684\u4e00\u79cdlambda\u8868\u8fbe\u5f0f\uff0c\u6216\u8005\u8bf4\u662f\u5bf9lambda\u8868\u8fbe\u5f0f\u7684\u4e00\u79cd\u8fdb\u4e00\u6b65\u7b80\u5316\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class User {  \n    private String username;  \n    private Integer age;  \n  \n    public User() {  \n    }  \n  \n    public User(String username, Integer age) {  \n        this.username = username;  \n        this.age = age;  \n    }  \n  \n    @Override  \n    public String toString() {  \n        return \"User{\" +  \n                \"username='\" + username + '\\'' +  \n                \", age=\" + age +  \n                '}';  \n    }  \n  \n    \/\/ Getter&amp;Setter  \n}  \n\n\npublic static void main(String[] args) {  \n    \/\/ \u4f7f\u7528\u53cc\u5192\u53f7::\u6765\u6784\u9020\u9759\u6001\u51fd\u6570\u5f15\u7528  \n    Function&lt;String, Integer> fun = Integer::parseInt;  \n    Integer value = fun.apply(\"123\");  \n    System.out.println(value);  \n  \n    \/\/ \u4f7f\u7528\u53cc\u5192\u53f7::\u6765\u6784\u9020\u975e\u9759\u6001\u51fd\u6570\u5f15\u7528  \n    String content = \"Hello JDK8\";  \n    Function&lt;Integer, String> func = content::substring;  \n    String result = func.apply(1);  \n    System.out.println(result);  \n  \n    \/\/ \u6784\u9020\u51fd\u6570\u5f15\u7528  \n    BiFunction&lt;String, Integer, User> biFunction = User::new;  \n    User user = biFunction.apply(\"mengday\", 28);  \n    System.out.println(user.toString());  \n  \n    \/\/ \u51fd\u6570\u5f15\u7528\u4e5f\u662f\u4e00\u79cd\u51fd\u6570\u5f0f\u63a5\u53e3\uff0c\u6240\u4ee5\u4e5f\u53ef\u4ee5\u5c06\u51fd\u6570\u5f15\u7528\u4f5c\u4e3a\u65b9\u6cd5\u7684\u53c2\u6570  \n    sayHello(String::toUpperCase, \"hello\");  \n}  \n\n\/\/ \u65b9\u6cd5\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u4e00\u4e2a\u662f  \nprivate static void sayHello(Function&lt;String, String> func, String parameter){  \n    String result = func.apply(parameter);  \n    System.out.println(result);  \n}<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u65b9\u6cd5\u5f15\u7528\u7684\u683c\u5f0f\u4e3a<code>&lt;ClassName | instance&gt;::&lt;MethodName&gt;<\/code>\u3002\u4e5f\u5c31\u662f\u88ab\u5f15\u7528\u7684\u65b9\u6cd5\u6240\u5c5e\u7684\u7c7b\u540d\u548c\u65b9\u6cd5\u540d\u7528\u53cc\u5192\u53f7<code>::<\/code>\u9694\u5f00\uff0c\u6784\u9020\u5668\u65b9\u6cd5\u662f\u4e2a\u4f8b\u5916\uff0c\u5f15\u7528\u4f1a\u7528\u5230<code>new<\/code>\u5173\u952e\u5b57\uff0c\u603b\u7ed3\u4e86\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261.png\" alt=\"\" class=\"wp-image-6695\" width=\"490\" height=\"234\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261.png 1022w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261-300x144.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261-768x368.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261-830x398.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261-230x110.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261-350x168.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-261-480x230.png 480w\" sizes=\"(max-width: 490px) 100vw, 490px\" \/><\/figure><\/div>\n\n\n\n<p><strong>Java \u65b9\u6cd5\u5f15\u7528<\/strong>\u662f<strong>Java 8<\/strong>\u968f\u7740<strong>Lambda<\/strong>\u8868\u8fbe\u5f0f\u5f15\u5165\u7684\u65b0\u7279\u6027\u3002 \u53ef\u4ee5\u76f4\u63a5\u5f15\u7528\u5df2\u6709<strong>Java<\/strong>\u7c7b\u6216\u5bf9\u8c61\u7684\u65b9\u6cd5\u6216\u6784\u9020\u5668\u3002<strong>\u65b9\u6cd5\u5f15\u7528<\/strong>\u901a\u5e38\u4e0e<strong>Lambda<\/strong>\u8868\u8fbe\u5f0f\u7ed3\u5408\u4f7f\u7528\u4ee5\u7b80\u5316\u4ee3\u7801\u3002\u5176\u4f7f\u7528\u6761\u4ef6\u662f\uff1a<strong>Lambda\u8868\u8fbe\u5f0f\u7684\u4e3b\u4f53\u4ec5\u5305\u542b\u4e00\u4e2a\u8868\u8fbe\u5f0f\uff0c\u4e14Lambda\u8868\u8fbe\u5f0f\u53ea\u8c03\u7528\u4e86\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u65b9\u6cd5\uff1b\u88ab\u5f15\u7528\u7684\u65b9\u6cd5\u7684\u53c2\u6570\u5217\u8868\u548c\u8fd4\u56de\u503c\u4e0eLambda\u8868\u8fbe\u5f0f\u7684\u8f93\u5165\u8f93\u51fa\u4e00\u81f4<\/strong>\u3002<\/p>\n\n\n\n<p>\u5f62\u5982 <strong>ClassName::methodName<\/strong> \u6216\u8005 <strong>objectName::methodName<\/strong> \u7684<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=%E8%A1%A8%E8%BE%BE%E5%BC%8F&amp;spm=1001.2101.3001.7020\" target=\"_blank\">\u8868\u8fbe\u5f0f<\/a>\uff0c\u53eb\u505a\u65b9\u6cd5\u5f15\u7528(Method Reference)\u3002\u770b\u770b\u7f16\u8bd1\u5668\u662f\u5982\u4f55\u6839\u636e \u201c\u6666\u6da9\u96be\u61c2\u201d \u7684 Method Reference \u6765\u63a8\u65ad\u5f00\u53d1\u8005\u7684\u610f\u56fe\u7684\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">1.\u8868\u8fbe\u5f0f\uff1a\nperson -> person.getName();\n\u53ef\u4ee5\u66ff\u6362\u6210\uff1a\nPerson::getName\n\n2.\u8868\u8fbe\u5f0f\uff1a\n() -> new HashMap&lt;>();\n\u53ef\u4ee5\u66ff\u6362\u6210\uff1a\nHashMap::new<\/pre>\n\n\n\n<p>\u5b98\u65b9\u6587\u6863\u4e2d\u5c06\u53cc\u5192\u53f7\u7684\u7528\u6cd5\u5206\u4e3a\u4e86\u4ee5\u4e0b4\u7c7b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-1024x326.png\" alt=\"\" class=\"wp-image-6689\" width=\"591\" height=\"188\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-1024x326.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-300x96.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-768x245.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-830x264.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-230x73.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-350x111.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257-480x153.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-257.png 1482w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u53cc\u5192\u53f7\u7684\u4f5c\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728\u4f7f\u7528\u53cc\u5192\u53f7\u524d\u6211\u4eec\u8981\u5148\u641e\u6e05\u695a\u4e00\u4e2a\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u53cc\u5192\u53f7\uff1f\u4e5f\u5c31\u662f\u53cc\u5192\u53f7\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u3002<\/p>\n\n\n\n<p>\u53cc\u5192\u53f7\u7684\u8bbe\u8ba1\u521d\u8877\u662f\u4e3a\u4e86\u5316\u7b80Lambda\u8868\u8fbe\u5f0f\uff0c\u4e0d\u719f\u6089Lambda\u8868\u8fbe\u5f0f\u7684\u540c\u5b66\u53ef\u4ee5\u5148\u4e86\u89e3\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p>Lambda\u8868\u8fbe\u5f0f\u7684\u5f62\u5f0f\u6709\u4e24\u79cd\uff1a<\/p>\n\n\n\n<ul><li>\u5305\u542b\u5355\u72ec\u8868\u8fbe\u5f0f \uff1aparameters -&gt; an expression<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    list.forEach(item -> System.out.println(item));\n\n<\/pre>\n\n\n\n<ul><li>\u5305\u542b\u4ee3\u7801\u5757\uff1aparameters -&gt; { expressions }<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    list.forEach(item -> {\n         int numA = item.getNumA();\n         int numB = item.getNumB();\n         System.out.println(numA + numB);\n    });\n\n<\/pre>\n\n\n\n<p>\u4f7f\u7528\u53cc\u5192\u53f7\u53ef\u4ee5\u7701\u7565\u7b2c\u4e00\u79cdLambda\u8868\u8fbe\u5f0f\u4e2d\u7684\u53c2\u6570\u90e8\u5206\uff0c\u5373item -&gt;\u548c\u8c03\u7528\u65b9\u6cd5\u7684\u53c2\u6570\u8fd9\u4e24\u90e8\u5206\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    \/\/\u4e0d\u4f7f\u7528\u53cc\u5192\u53f7\n    list.forEach(item -> System.out.println(item));\n    \/\/\u4f7f\u7528\u53cc\u5192\u53f7\n    list.forEach(System.out::println);\n\n<\/pre>\n\n\n\n<p><strong>\u53cc\u5192\u53f7\u7684\u4f7f\u7528\u6761\u4ef6<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4f7f\u7528\u53cc\u5192\u53f7\u6709\u4e24\u4e2a\u6761\u4ef6\uff1a<\/p>\n\n\n\n<ul><li>\u6761\u4ef61\uff1a\u6761\u4ef61\u4e3a\u5fc5\u8981\u6761\u4ef6\uff0c\u5fc5\u987b\u8981\u6ee1\u8db3\u8fd9\u4e2a\u6761\u4ef6\u624d\u80fd\u4f7f\u7528\u53cc\u5192\u53f7\u3002Lambda\u8868\u8fbe\u5f0f\u5185\u90e8\u53ea\u6709\u4e00\u6761\u8868\u8fbe\u5f0f\uff08\u7b2c\u4e00\u79cdLambda\u8868\u8fbe\u5f0f\uff09\uff0c\u5e76\u4e14\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u53ea\u662f\u8c03\u7528\u5df2\u7ecf\u5b58\u5728\u7684\u65b9\u6cd5\uff0c\u4e0d\u505a\u5176\u4ed6\u7684\u64cd\u4f5c\u3002<\/li><li>\u6761\u4ef62\uff1a\u7531\u4e8e\u53cc\u5192\u53f7\u662f\u4e3a\u4e86\u7701\u7565item -&gt;\u8fd9\u4e00\u90e8\u5206\uff0c\u6240\u4ee5\u6761\u4ef62\u662f\u9700\u8981\u6ee1\u8db3\u4e0d\u9700\u8981\u5199\u53c2\u6570item\u4e5f\u77e5\u9053\u5982\u4f55\u4f7f\u7528item\u7684\u60c5\u51b5\u3002<\/li><\/ul>\n\n\n\n<p>\u6709\u4e24\u79cd\u60c5\u51b5\u53ef\u4ee5\u6ee1\u8db3\u8fd9\u4e2a\u8981\u6c42\uff0c\u8fd9\u5c31\u662f\u6211\u5c06\u53cc\u5192\u53f7\u7684\u4f7f\u7528\u5206\u4e3a2\u7c7b\u7684\u4f9d\u636e\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-1024x203.png\" alt=\"\" class=\"wp-image-6690\" width=\"632\" height=\"125\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-1024x203.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-300x59.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-768x152.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-830x164.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-230x46.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-350x69.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258-480x95.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-258.png 1484w\" sizes=\"(max-width: 632px) 100vw, 632px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-1024x605.png\" alt=\"\" class=\"wp-image-6692\" width=\"507\" height=\"299\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-1024x605.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-300x177.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-768x454.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-830x491.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-230x136.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-350x207.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259-480x284.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-259.png 1316w\" sizes=\"(max-width: 507px) 100vw, 507px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-1024x704.png\" alt=\"\" class=\"wp-image-6693\" width=\"481\" height=\"330\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-1024x704.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-300x206.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-768x528.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-830x570.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-230x158.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-350x240.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260-480x330.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-260.png 1336w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u4e00\u4e9b\u4f8b\u5b50\uff1a<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Lambda\u8868\u8fbe\u5f0f\u7684\u53c2\u6570\u4e0e\u8c03\u7528\u51fd\u6570\u7684\u53c2\u6570\u5b8c\u5168\u4e00\u81f4\u65f6<\/p>\n\n\n\n<p><strong>\u9759\u6001\u65b9\u6cd5\u8c03\u7528<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    \/\/\u5316\u7b80\u524d\n    list.forEach(item -> System.out.println(item));\n    \/\/\u5316\u7b80\u540e\n    list.forEach(System.out::println);\n\n<\/pre>\n\n\n\n<p><strong>\u975e\u9759\u6001\u65b9\u6cd5\u8c03\u7528<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    StringBuilder stringBuilder = new StringBuilder();\n    \/\/\u5316\u7b80\u524d\n    IntStream.range(1, 101).forEach(item -> stringBuilder.append(item));\n    \/\/\u5316\u7b80\u540e\n    IntStream.range(1, 101).forEach(stringBuilder::append);\n\n<\/pre>\n\n\n\n<p><strong>\u8c03\u7528\u6784\u9020\u65b9\u6cd5<\/strong><\/p>\n\n\n\n<p>\u5148\u5b9a\u4e49\u4e00\u4e2a\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7684\u4f5c\u7528\u662f\u5c06\u4e00\u4e2a\u96c6\u5408\u7684\u5185\u5bb9\u590d\u5236\u5230\u53e6\u4e00\u4e2a\u96c6\u5408<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    public &lt;T, SOURCE extends Collection&lt;T>, DEST extends Collection&lt;T>>\n    DEST transferElements(SOURCE sourceCollection, Supplier&lt;DEST> collectionFactory) {\n         DEST result = collectionFactory.get();\n         result.addAll(sourceCollection);\n         return result;\n    }\n\n<\/pre>\n\n\n\n<p>\u8c03\u7528\u8fd9\u4e2a\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    \/\/\u5316\u7b80\u524d\n    Set&lt;Person> rosterSetLambda = transferElements(roster, () -> new HashSet&lt;>());\n    \/\/\u5316\u7b80\u540e\n    Set&lt;Person> rosterSet = transferElements(roster, HashSet::new);\n\n<\/pre>\n\n\n\n<p><strong>\u81ea\u5df1\u5199\u7684\u4e00\u4e2a\u4f8b\u5b50<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u7b2c\u4e00\u4e2a\u7c7b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Data\npublic class ModelA {\n     private String id;\n \n     public ModelA(String id) {\n     this.id = id;\n     }\n \n     public ModelA() {\n     }\n}<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ClassB {\n     private final List&lt;ModelA> list = new ArrayList&lt;>();\n \n     public void add(String string, Function&lt;String, ModelA> function) {\n     list.add(function.apply(string));\n     }\n}<\/pre>\n\n\n\n<p>\u6d4b\u8bd5\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    ClassB classB = new ClassB();\n    \/\/\u5316\u7b80\u524d\n    classB.add(\"ddd\", item -> new ModelA(item));\n    \/\/\u5316\u7b80\u540e\n    classB.add(\"ddd\", ModelA::new);\n\n<\/pre>\n\n\n\n<p><strong>\u53e6\u4e00\u4e2a\u4f8b\u5b50<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>JDK8\u4e2d\u6709\u53cc\u5192\u53f7\u7684\u7528\u6cd5\uff0c\u5c31\u662f\u628a\u65b9\u6cd5\u5f53\u505a\u53c2\u6570\u4f20\u5230stream\u5185\u90e8\uff0c\u4f7fstream\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u4f20\u5165\u5230\u8be5\u65b9\u6cd5\u91cc\u9762\u6267\u884c\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p>\u4ee3\u7801\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u4ee5\u524d\u7684\u4ee3\u7801\u4e00\u822c\u662f\u5982\u6b64\u7684\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class AcceptMethod {\n \n    public static void  printValur(String str){\n        System.out.println(\"print value : \"+str);\n    }\n \n    public static void main(String[] args) {\n        List&lt;String> al = Arrays.asList(\"a\",\"b\",\"c\",\"d\");\n        for (String a: al) {\n            AcceptMethod.printValur(a);\n        }\n      \/\/\u4e0b\u9762\u7684for each\u5faa\u73af\u548c\u4e0a\u9762\u7684\u5faa\u73af\u662f\u7b49\u4ef7\u7684 \n        al.forEach(x->{\n            AcceptMethod.printValur(x);\n        });\n    }\n}<\/pre>\n\n\n\n<p>\u73b0\u5728JDK\u53cc\u5192\u53f7\u662f\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class MyTest {\n    public static void  printValur(String str){\n        System.out.println(\"print value : \"+str);\n    }\n \n    public static void main(String[] args) {\n        List&lt;String> al = Arrays.asList(\"a\", \"b\", \"c\", \"d\");\n        al.forEach(AcceptMethod::printValur);\n        \/\/\u4e0b\u9762\u7684\u65b9\u6cd5\u548c\u4e0a\u9762\u7b49\u4ef7\u7684\n        Consumer&lt;String> methodParam = AcceptMethod::printValur; \/\/\u65b9\u6cd5\u53c2\u6570\n        al.forEach(x -> methodParam.accept(x));\/\/\u65b9\u6cd5\u6267\u884caccept\n    }\n}<\/pre>\n\n\n\n<p>\u4e0a\u9762\u7684\u6240\u6709\u65b9\u6cd5\u6267\u884c\u73a9\u7684\u7ed3\u679c\u90fd\u662f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">print value : a\nprint value : b\nprint value : c\nprint value : d<\/pre>\n\n\n\n<p>JDK\u6e90\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/**\n     * Performs the given action for each element of the {@code Iterable}\n     * until all elements have been processed or the action throws an\n     * exception.  Unless otherwise specified by the implementing class,\n     * actions are performed in the order of iteration (if an iteration order\n     * is specified).  Exceptions thrown by the action are relayed to the\n     * caller.\n     *\n     * @implSpec\n     * &lt;p>The default implementation behaves as if:\n     * &lt;pre>{@code\n     *     for (T t : this)\n     *         action.accept(t);\n     * }&lt;\/pre>\n     *\n     * @param action The action to be performed for each element\n     * @throws NullPointerException if the specified action is null\n     * @since 1.8\n     *\/\n    default void forEach(Consumer&lt;? super T> action) {\n        Objects.requireNonNull(action);\n        for (T t : this) {\n            action.accept(t);\n        }\n    }<\/pre>\n\n\n\n<p><strong>\u9644\uff1a\u77e5\u4e4e\u7684\u4e00\u4e2a\u4f8b\u5b50\uff08\u6bd4\u8f83\u597d\u7684\u4f8b\u5b50\uff09<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u53cc\u5192\u53f7::\u5728JDK8\u7684Lambda\u8868\u8fbe\u5f0f\u51fd\u6570\u4e2d\u5f00\u59cb\u4f7f\u7528\uff0c\u7528\u4f5c\u65b9\u6cd5\u5f15\u7528\u3002<\/p>\n\n\n\n<p>\u5177\u4f53\u7528\u6cd5\uff0c\u54b1\u4eec\u6765\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<p>\u5047\u8bbe\u6709\u4e2aPerson\u7c7b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class Person {\n\n    public enum Sex {\n        MALE, FEMALE\n    }\n\n    String name;\n    LocalDate birthday;\n    Sex gender;\n    String emailAddress;\n\n    public int getAge() {\n        \/\/ ...\n    }\n    \n    public Calendar getBirthday() {\n        return birthday;\n    }    \n\n    public static int compareByAge(Person a, Person b) {\n        return a.birthday.compareTo(b.birthday);\n    }}<\/pre>\n\n\n\n<p>\u5047\u8bbe\u4f60\u7684\u793e\u4ea4\u7f51\u7edc\u5e94\u7528\u7a0b\u5e8f\u7684\u6210\u5458\u5305\u542b\u5728\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff0c\u5e76\u4e14\u4f60\u5e0c\u671b\u6309\u5e74\u9f84\u5bf9\u6570\u7ec4\u8fdb\u884c\u6392\u5e8f\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Person[] rosterAsArray = roster.toArray(new Person[roster.size()]);\n\nclass PersonAgeComparator implements Comparator&lt;Person> {\n    public int compare(Person a, Person b) {\n        return a.getBirthday().compareTo(b.getBirthday());\n    }\n}\n        \nArrays.sort(rosterAsArray, new PersonAgeComparator());\n\n<\/pre>\n\n\n\n<p>\u4e0a\u9762\u6700\u540e\u4e00\u884c\u4ee3\u7801\uff1aArrays.sort\u4e2d\u7684sort\u65b9\u6cd5\u6e90\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">static &lt;T> void sort(T[] a, Comparator&lt;? super T> c)<\/pre>\n\n\n\n<p>\u8bf7\u6ce8\u610f\uff0c\u6b64\u65f6\u7684\u63a5\u53e3Comparator\u662f\u4e00\u4e2a\u7528 <a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/www.zhihu.com\/people\/d508d8faab94ce24f178d83882036702\">@Functional<\/a> \u6765\u6ce8\u89e3\u7684\uff0c\u56e0\u6b64\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528lambda\u8868\u8fbe\u5f0f\uff0c\u800c\u4e0d\u662f\u5b9a\u4e49\u5e76\u521b\u5efa\u5b9e\u73b0comparator\u7684\u7c7b\u7684\u65b0\u5b9e\u4f8b\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u7528\u4e00\u4e2aLambda\u8868\u8fbe\u5f0f\u6765\u5199\u65b9\u6cd5\u5b9a\u4e49\uff0c\u6765\u521b\u5efaComparator\u7684\u5b9e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Arrays.sort(rosterAsArray,\n    (Person a, Person b) -> {\n        return a.getBirthday().compareTo(b.getBirthday());\n    }\n);<\/pre>\n\n\n\n<p>\u4f46\u662f\uff0c\u6211\u4eec\u5df2\u7ecf\u5728Person bean\u5bf9\u8c61\u4e2d\u63d0\u524d\u5199\u597d\u4e86\u7528\u6765\u6bd4\u8f83\u4e24\u4e2aperson\u5bf9\u8c61\u7684\u51fa\u751f\u65e5\u671f\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262.png\" alt=\"\" class=\"wp-image-6705\" width=\"567\" height=\"34\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262.png 850w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262-300x18.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262-768x47.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262-830x51.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262-230x14.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262-350x21.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-262-480x29.png 480w\" sizes=\"(max-width: 567px) 100vw, 567px\" \/><\/figure><\/div>\n\n\n\n<p>\u6240\u4ee5\u4f60\u5176\u5b9e\u53ef\u4ee5\u5728lambda\u8868\u8fbe\u5f0f\u7684\u4e3b\u4f53\u4e2d\u76f4\u63a5\u8c03\u7528\u8fd9\u4e2a\u65b9\u6cd5\u65b9\u6cd5\uff0c\u5728Person.compareByAge\u51fd\u6570\u4e2d\uff0c\u5176instance\u5df2\u5b58\u5728\uff0c\u6240\u4ee5\u6211\u4eec\u8981\u6bd4\u8f83\u4e24\u4e2aPerson\u5b9e\u4f8b\u7684\u5e74\u9f84\u5927\u5c0f\uff0c\u7528Lambda expression\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Arrays.sort(rosterAsArray,\n  (Person a, Person b) -> {\n    return a.getBirthday().compareTo(b.getBirthday());\n  }\n);<\/pre>\n\n\n\n<p>\u56e0\u4e3a\u8fd9\u4e2a\u4e0a\u9762\u8fd9\u4e2alambda\u8868\u8fbe\u5f0f\u662f\u5728\u8c03\u7528\u73b0\u6709\u7684\u65b9\u6cd5\uff0c\u6240\u4ee5\u6211\u4eec\u8fd9\u91cc\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e0a\u9762\u63d0\u5230\u7684\u4f7f\u7528\u65b9\u6cd5\u5f15\u7528\u65b9\u5f0f\uff08\u53ca\u53cc\u5192\u53f7 ::\uff09\uff0c\u800c\u4e0d\u662f\u4e4b\u524d\u6211\u4eec\u719f\u6089\u7684lambda\u8868\u8fbe\u5f0f\uff0c\u7531\u4e8e\u54b1\u4eec\u7684Lambda\u8868\u8fbe\u5f0f\u8c03\u7528\u7684\u662f\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u65b9\u6cd5\uff0c\u5373\uff0c\u6211\u4eec\u505a\u7684\u5c31\u662f<strong><em>\u65b9\u6cd5\u5f15\u7528<\/em><\/strong>\uff0c\u6240\u4ee5\u4f60\u5c31\u53ef\u4ee5\u7528\u53cc\u5192\u53f7::\u6765\u6539\u9020\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Arrays.sort(rosterAsArray, Person::compareByAge);<\/pre>\n\n\n\n<p>\u65b9\u6cd5\u5f15\u7528 person\uff1a\uff1acomparebyage \u5728\u8bed\u4e49\u4e0a\u4e0elambda\u8868\u8fbe\u5f0f\uff08a\uff0cb\uff09-&gt;person.comparebyage\uff08a\uff0cb\uff09\u76f8\u540c\u3002\u4ed6\u4eec\u90fd\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a<\/p>\n\n\n\n<ul><li>\u5b83\u7684\u5f62\u53c2\u5217\u8868\u590d\u5236\u81eacomparator&lt;person&gt;.compare\uff0c\u5373<code>(Person, Person)<\/code>\u3002<\/li><li>\u5b83\u7684\u4e3b\u4f53\u8c03\u7528\u65b9\u6cd5\u662f\uff1aperson.comparebyage\u3002<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5176\u5b9e\uff0cJVM \u672c\u8eab\u5e76\u4e0d\u652f\u6301\u6307\u5411\u65b9\u6cd5\u5f15\u7528\uff0c\u8fc7\u53bb\u4e0d\u652f\u6301\uff0c\u73b0\u5728\u4e5f\u4e0d\u652f\u6301\u3002Java 8 \u5bf9\u65b9\u6cd5\u5f15\u7528\u7684\u652f\u6301\u53ea\u662f\u7f16\u8bd1\u5668\u5c42\u9762\u7684\u652f\u6301\uff0c\u865a\u62df\u673a\u6267\u884c\u5f15\u64ce\u5e76\u4e0d\u4e86\u89e3\u65b9\u6cd5\u5f15\u7528\u3002\u7f16\u8bd1\u5668\u9047\u5230\u65b9\u6cd5\u5f15\u7528\u7684\u65f6\u5019\uff0c\u4f1a\u50cf\u4e0a\u9762\u90a3\u6837\u81ea\u52a8\u63a8\u65ad\u51fa\u5f00\u53d1\u8005\u7684\u610f\u56fe\uff0c\u5c06\u65b9\u6cd5\u5f15\u7528\u8fd8\u539f\u6210\u63a5\u53e3\u5b9e\u73b0\u5bf9\u8c61\uff0c\u6216\u8005\u66f4\u5f62\u8c61\u5730\u8bf4\uff0c\u5c31\u662f\u628a\u65b9\u6cd5\u5f15\u7528\u8bbe\u6cd5\u5305\u88c5\u6210\u4e00\u4e2a\u63a5\u53e3\u5b9e\u73b0\u5bf9\u8c61\uff0c\u8fd9\u6837\u865a\u62df\u673a\u5c31\u53ef\u4ee5\u65e0\u5dee\u522b\u5730\u6267\u884c\u5b57\u8282\u7801\u6587\u4ef6\u800c\u4e0d\u9700\u8981\u7ba1\u4ec0\u4e48\u662f\u65b9\u6cd5\u5f15\u7528\u4e86\u3002<\/p>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u65b9\u6cd5\u5f15\u7528\u662f\u7528\u6765\u7b80\u5316\u63a5\u53e3\u5b9e\u73b0\u4ee3\u7801\u7684\uff0c\u5e76\u4e14\u51e1\u662f\u80fd\u591f\u7528\u65b9\u6cd5\u5f15\u7528\u6765\u7b80\u5316\u7684\u63a5\u53e3\uff0c\u90fd\u6709\u8fd9\u6837\u7684\u7279\u5f81\uff1a\u6709\u4e14\u53ea\u6709\u4e00\u4e2a\u5f85\u5b9e\u73b0\u7684\u65b9\u6cd5\u3002\u8fd9\u79cd\u63a5\u53e3\u5728 Java \u4e2d\u6709\u4e2a\u4e13\u95e8\u7684\u540d\u79f0\uff1a \u51fd\u6570\u5f0f\u63a5\u53e3\u3002\u5f53\u8bd5\u56fe\u7528\u65b9\u6cd5\u5f15\u7528\u66ff\u4ee3\u4e00\u4e2a\u975e\u51fd\u6570\u5f0f\u63a5\u53e3\u65f6\uff0c\u4f1a\u6709\u8fd9\u6837\u7684\u9519\u8bef\u63d0\u793a\uff1a xxx is not a functional interface\u3002<\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53cc\u5192\u53f7\u201c::\u201d\u5c31\u662f Java \u4e2d\u7684\u65b9\u6cd5\u5f15\u7528(Method references) \u65b9\u6cd5\u5f15\u7528\u7684\u683c\u5f0f\u662f\u7c7b\u540d::\u65b9\u6cd5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6688"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6688"}],"version-history":[{"count":12,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6688\/revisions"}],"predecessor-version":[{"id":13225,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6688\/revisions\/13225"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}