{"id":12507,"date":"2023-08-30T20:30:11","date_gmt":"2023-08-30T12:30:11","guid":{"rendered":"https:\/\/92it.top\/?p=12507"},"modified":"2023-08-30T20:30:11","modified_gmt":"2023-08-30T12:30:11","slug":"%e8%bf%99%e4%b9%88%e7%ae%80%e5%8d%95%ef%bc%8c%e8%bf%98%e4%b8%8d%e4%bc%9a%e4%bd%bf%e7%94%a8java8-stream%e6%b5%81%e7%9a%84map%e6%96%b9%e6%b3%95%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=12507","title":{"rendered":"\u8fd9\u4e48\u7b80\u5355\uff0c\u8fd8\u4e0d\u4f1a\u4f7f\u7528java8 stream\u6d41\u7684map()\u65b9\u6cd5\u5417\uff1f"},"content":{"rendered":"\n<p><strong>\u4e00\u3001\u524d\u8a00<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728\u65e5\u5e38\u7684\u5f00\u53d1\u5de5\u4f5c\u4e2d\u7ecf\u5e38\u78b0\u5230\u8981\u5904\u7406list\u4e2d\u6570\u636e\u7684\u95ee\u9898\uff0c\u6bd4\u5982\u4ece\u6570\u636e\u5e93\u4e2d\u67e5\u51fa\u4e86\u5f88\u591a\u5b66\u751f\uff0c\u7531\u4e8e\u4e00\u4e9b\u539f\u56e0\u9700\u8981\u5728\u5185\u5b58\u4e2d\u627e\u51fa\u8fd9\u4e9b\u5b66\u751f\u4e2d\u7684\u6240\u6709\u59d3\u540d\uff0c\u6216\u8005\u628a\u540d\u4e3a\u201c\u738b\u4e94\u201d\u7684\u8bed\u6587\u6210\u7ee9\u6682\u65f6\u4fee\u6539\u4e3a\u201c100\u201d\uff0c\u8fd9\u4e9b\u95ee\u9898\u600e\u4e48\u5904\u7406\u5450\uff0c\u4e4b\u524d\u6211\u4eec\u60f3\u5230\u7684\u662f\u904d\u5386\u6bcf\u4e2a\u5143\u7d20\uff0c\u7136\u540e\u53d6\u51fa\u6765\u653e\u5230\u53e6\u5916\u4e00\u4e2a\u96c6\u5408\u4e2d\uff0c\u5728java8\u4e2d\u5bf9\u96c6\u5408\u53ef\u4ee5\u8fdb\u884c\u6d41\u5f0f\u64cd\u4f5c\u4f7f\u4e0a\u9762\u7684\u5904\u7406\u66f4\u7b80\u6d01\u3002\u4eca\u5929\u6765\u770b\u4e0bmap()\u65b9\u6cd5\u7684\u4f7f\u7528\u3002<\/p>\n\n\n\n<p><strong>\u4e8c\u3001\u6982\u8ff0<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><br>stram\u6d41\u5f0f\u5904\u7406\u4e2d\u6709<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=map%E6%96%B9%E6%B3%95&amp;spm=1001.2101.3001.7020\" target=\"_blank\">map\u65b9\u6cd5<\/a>\uff0c\u5148\u770b\u4e0b\u5176\u5b9a\u4e49\uff0c\u8be5\u65b9\u6cd5\u5728java.util.stream.Stream\u7c7b\u4e2d<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-1024x307.png\" alt=\"\" class=\"wp-image-12508\" width=\"500\" height=\"149\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-1024x307.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-300x90.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-768x230.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-1536x461.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-830x249.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-230x69.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-350x105.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333-480x144.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-333.png 1634w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<p id=\"1669818243207\">\u53ef\u4ee5\u770b\u5230map()\u65b9\u6cd5\u63a5\u6536\u4e00\u4e2a<a href=\"https:\/\/so.csdn.net\/so\/search?q=%E5%87%BD%E6%95%B0%E5%BC%8F%E6%8E%A5%E5%8F%A3&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\">\u51fd\u6570\u5f0f\u63a5\u53e3<\/a>\u53c2\u6570\uff0c\u5165\u53c2\u6709\u4e00\u4e2aT\uff0c\u8fd4\u56de\u4e00\u4e2aStream\u6d41\uff0c\u8fd9\u4e2a\u6d41\u662fR\u6cdb\u578b\u3002\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u70b9\u6ce8\u610f\uff0c<\/p>\n\n\n\n<ol><li>\u5165\u53c2\u662f\u4e00\u4e2a\u6d41\u4e2d\u7684\u5143\u7d20\uff1b<\/li><li>\u51fa\u53c2\u662f\u4e00\u4e2a\u6d41\uff0c\u4e14\u6d41\u4e2d\u662f\u65b0\u5143\u7d20\uff1b<\/li><\/ol>\n\n\n\n<p>\u7528\u56fe\u8868\u793a\u5c31\u662f\u4e0b\u9762\u7684\u6837\u5b50\uff0c<strong>\u539f\u59cb\u6d41\u4e2d\u6709\u56db\u4e2a\u5706\u5f62\u56fe\u6848\uff0c\u8c03\u7528map()\u51fd\u6570\u540e\u53d8\u6210\u4e86\u56db\u4e2a\u4e94\u89d2\u661f\u56fe\u6848\uff0c\u8fd9\u91cc\u7684\u5706\u5f62\u56fe\u6848\u548c\u4e94\u89d2\u661f\u56fe\u6848\u662f\u4e00\u4e00\u5bf9\u5e94\u7684\uff0c\u4e5f\u5c31\u662f\u539f\u59cb\u6d41\u4e2d\u6709\u591a\u5c11\u4e2a\u5143\u7d20\uff0c\u8c03\u7528map()\u65b9\u6cd5\u540e\u4f9d\u65e7\u6709\u591a\u5c11\u4e2a\u5143\u7d20\uff0c\u552f\u4e00\u6539\u53d8\u7684\u662f\u6d41\u4e2d\u7684\u5143\u7d20\u7c7b\u578b\u3002<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-1024x610.png\" alt=\"\" class=\"wp-image-12509\" width=\"490\" height=\"291\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-1024x610.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-300x179.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-768x458.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-830x495.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-230x137.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-350x209.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334-480x286.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-334.png 1272w\" sizes=\"(max-width: 490px) 100vw, 490px\" \/><\/figure><\/div>\n\n\n\n<p>\u597d\u4e86\uff0c\u4e0b\u9762\u770b\u4e0b\u600e\u4e48\u4f7f\u7528map()\u51fd\u6570\u3002<\/p>\n\n\n\n<p><strong>\u4e09\u3001\u8be6\u8ff0<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4ee5Student\u4e3a\u4f8b\uff0c<\/p>\n\n\n\n<p>Student.java<\/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=\"\">package com.example.log.stream.entity;\nimport java.io.Serializable;\n\/**\n * \u5b66\u751f\u7c7b\n * @date 2022\/11\/30 20:40\n *\/\npublic class Student implements Serializable {\n    \/**\n     * \u59d3\u540d\n     *\/\n    private String name;\n    \/**\n     * \u73ed\u7ea7\n     *\/\n    private String schoolClass;\n \n    \/**\n     *\u8bed\u6587\u6210\u7ee9\n     *\/\n    private Integer chineseScore;\n    \/**\n     * \u6570\u5b66\u6210\u7ee9\n     *\/\n    private Integer MathScore;\n    \n    \/\/\u7701\u7565get\u3001set\u65b9\u6cd5\n}<\/pre>\n\n\n\n<p>\u6709\u4e00\u4e2a\u521d\u59cb\u5316\u6570\u636e\u7684\u7c7b\uff0c\u7528\u6765\u521d\u59cb\u5316\u4e00\u4e2aList<\/p>\n\n\n\n<p>Data.java<\/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=\"\">package com.example.log.stream.test;\n \nimport com.example.log.stream.entity.Student;\n \nimport java.util.ArrayList;\nimport java.util.List;\n \n\/**\n * @date 2022\/11\/30 22:43\n *\/\npublic class Data {\n    public static List&lt;Student> initData(){\n        List&lt;Student> students= new ArrayList&lt;>();\n        Student s1=new Student();\n        s1.setName(\"\u738b\u4e94\");\n        s1.setSchoolClass(\"\u4e00\u5e74\u7ea7\");\n        s1.setChineseScore(100);\n        s1.setMathScore(100);\n        students.add(s1);\n \n        Student s2=new Student();\n        s2.setName(\"\u674e\u56db\");\n        s2.setSchoolClass(\"\u4e00\u5e74\u7ea7\");\n        s2.setChineseScore(100);\n        s2.setMathScore(100);\n        students.add(s2);\n \n        Student s3=new Student();\n        s3.setName(\"\u674e\u601d\");\n        s3.setSchoolClass(\"\u4e8c\u5e74\u7ea7\");\n        s3.setChineseScore(100);\n        s3.setMathScore(100);\n        students.add(s3);\n \n        Student s4=new Student();\n        s4.setName(\"\u738b\u4e94\");\n        s4.setSchoolClass(\"\u4e09\u5e74\u7ea7\");\n        s4.setChineseScore(100);\n        s4.setMathScore(100);\n        students.add(s4);\n \n        Student s5=new Student();\n        s5.setName(\"\u8d75\u4e09\");\n        s5.setSchoolClass(\"\u4e00\u5e74\u7ea7\");\n        s5.setChineseScore(100);\n        s5.setMathScore(100);\n        students.add(s5);\n        return students;\n    }\n}<\/pre>\n\n\n\n<p>\u4e0b\u9762\u6839\u636e\u4e0a\u9762\u7684\u6570\u636e\uff0c\u8fdb\u884c\u4e0b\u9762\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p><strong>3.1\u3001\u627e\u51fa\u6240\u6709\u7684\u5b66\u751f\u59d3\u540d<\/strong><\/p>\n\n\n\n<p>TestMap.java<\/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=\"\">package com.example.log.stream.test;\n \nimport com.example.log.stream.entity.Student;\n \nimport java.util.ArrayList;\nimport java.util.List;\n \n\/**\n * \u6d4b\u8bd5map\u65b9\u6cd5\n * @date 2022\/11\/30 21:25\n *\/\npublic class TestMap {\n    public static void main(String[] args) {\n        List&lt;Student> students=Data.initData();\n        students.stream().map(student -> student.getName()).forEach(System.out::println);\n    }\n \n}<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u4f7f\u7528\u4e86map()\u65b9\u6cd5\uff0c\u5165\u53c2\u662fStudent\uff0c\u51fa\u53c2\u662f\u4ee5String\u4e3a\u6cdb\u578b\u7684\u6d41\uff0c\u6700\u540e\u4f7f\u7528forEach\u8fdb\u884c\u4e86\u6253\u5370\uff0c\u770b\u4e0b\u7ed3\u679c:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-1024x393.png\" alt=\"\" class=\"wp-image-12510\" width=\"503\" height=\"193\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-1024x393.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-300x115.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-768x295.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-830x319.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-230x88.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-350x134.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335-480x184.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-335.png 1198w\" sizes=\"(max-width: 503px) 100vw, 503px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u521a\u597d\u628a\u6240\u6709\u7684\u5b66\u751f\u59d3\u540d\u5747\u6253\u5370\u51fa\u6765\u4e86\u3002<strong>\u5982\u679c\u60f3\u628a\u8fd9\u4e9b\u5b66\u751f\u59d3\u540d\u653e\u5230\u4e00\u4e2aList\u4e2d\u600e\u4e48\u529e\uff1f<\/strong><\/p>\n\n\n\n<p><strong>3.1.1\u3001\u5c06\u5b66\u751f\u59d3\u540d\u653e\u5230list\u4e2d<\/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=\"\">package com.example.log.stream.test;\n \nimport com.example.log.stream.entity.Student;\n \nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.stream.Collectors;\n \n\/**\n * \u6d4b\u8bd5map\u65b9\u6cd5\n *\n * @author wangcj5\n * @date 2022\/11\/30 21:25\n *\/\npublic class TestMap {\n    public static void main(String[] args) {\n        List&lt;Student> students=Data.initData();\n\/\/        students.stream().map(student -> student.getName()).forEach(System.out::println);\n        \/\/\u5c06\u6240\u6709\u7684\u5b66\u751f\u59d3\u540d\u653e\u5230list\u4e2d\n        List&lt;String> studentNames=students.stream().map(student -> student.getName()).collect(Collectors.toList());\n     for (String studentName:studentNames) {\n      System.out.println(studentName);\n     }\n    }\n}<\/pre>\n\n\n\n<p>\u7ed3\u679c\u5982\u4e0b:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-336-1024x381.png\" alt=\"\" class=\"wp-image-12511\" width=\"552\" height=\"204\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-336-1024x381.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-336-300x112.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-336-230x86.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-336-350x130.png 350w\" sizes=\"(max-width: 552px) 100vw, 552px\" \/><\/figure><\/div>\n\n\n\n<p>\u540c\u6837\u7684\u627e\u51fa\u6240\u6709\u7684\u73ed\u7ea7\uff0c\u627e\u51fa\u6240\u6709\u5b66\u751f\u7684\u6210\u7ee9\u90fd\u53ef\u7c7b\u6bd4\u4e0a\u9762\u7684\uff0c\u53ef\u4ee5\u770b\u5230\u6253\u5370\u51fa\u7684\u5b66\u751f\u59d3\u540d\u6216\u73ed\u7ea7\u662f\u6709\u91cd\u590d\u6570\u636e\uff0c\u8fd9\u4e2a\u8981\u600e\u4e48\u89e3\u51b3\u3002\u6211\u4eec\u77e5\u9053\u5728\u6700\u540e\u662f\u628a\u6570\u636e\u653e\u5230list\u4e2d\uff0c\u4e3a\u4e86\u89e3\u51b3\u91cd\u590d\u7684\u95ee\u9898\u53ef\u4ee5\u628a\u6570\u636e\u653e\u5230set\u4e2d\uff0c\u5229\u7528set\u7684\u53bb\u91cd\u529f\u80fd<\/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=\"\">\/\/\u5c06\u5b66\u751f\u59d3\u540d\u653e\u5230Set\u4e2d\uff0c\u53ef\u4ee5\u5b9e\u73b0\u53bb\u91cd\u529f\u80fd\nSet&lt;String> studentNames=students.stream().map(student -> student.getName()).collect(Collectors.toSet());<\/pre>\n\n\n\n<p>\u7ed3\u679c\u4e0d\u518d\u6253\u5370\uff0c\u6709\u5174\u8da3\u7684\u53ef\u4ee5\u81ea\u5df1\u8bd5\u8bd5\u3002<\/p>\n\n\n\n<p><strong>3.2\u3001\u5c06\u59d3\u540d\u4e3a\u201c\u8d75\u4e09\u201d\u7684\u8bed\u6587\u6210\u7ee9\u7f6e\u4e3a90<\/strong><\/p>\n\n\n\n<p>\u73b0\u5728\u6709\u8fd9\u6837\u4e00\u4e2a\u9700\u6c42\uff0c\u8981\u628a\u59d3\u540d\u4e3a\u201c\u8d75\u4e09\u201d\u5b66\u751f\u7684\u8bed\u6587\u6210\u7ee9\u7f6e\u4e3a90\uff0c\u770b\u4e0b\u5229\u7528map()\u51fd\u6570\u600e\u4e48\u505a\uff1f<\/p>\n\n\n\n<p>TestMap2.java<\/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=\"\">package com.example.log.stream.test;\n \nimport com.example.log.stream.entity.Student;\n \nimport java.util.List;\nimport java.util.Set;\nimport java.util.stream.Collectors;\n \n\/**\n * \u6d4b\u8bd5map\u65b9\u6cd5\n * @date 2022\/11\/30 21:25\n *\/\npublic class TestMap2 {\n    public static void main(String[] args) {\n        List&lt;Student> students = Data.initData();\n \n        List&lt;Student> studentNames = students.stream().map(student -> {\n            if (\"\u8d75\u4e09\".equals(student.getName())) {\n                student.setChineseScore(90);\n            }\n            return student;\n        }).collect(Collectors.toList());\n \n        for (Student studentName : studentNames) {\n            System.out.println(studentName);\n        }\n        \/\/\u6253\u5370\u8001\u7684list\n        System.out.println(\"\u6539\u4e4b\u524d\u7684\u6570\u636e----------------\");\n        for (Student studentName : students) {\n            System.out.println(studentName);\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u770b\u4e0b\u6253\u5370\u7684\u7ed3\u679c \uff0c<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-1024x452.png\" alt=\"\" class=\"wp-image-12512\" width=\"550\" height=\"242\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-1024x452.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-300x132.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-768x339.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-1536x678.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-830x366.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-230x101.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-350x154.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337-480x212.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-337.png 1614w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n\n<p>\u4ece\u4e0a\u9762\u7684\u7ed3\u679c\u4e2d\u53ef\u4ee5\u770b\u51fa\uff0c\u201d\u8d75\u4e09\u201c\u7684\u8bed\u6587\u6210\u7ee9\u7684\u786e\u88ab\u6539\u4e3a\u4e86\u201d90\u201c\uff0c\u8fd9\u70b9\u662f\u6ca1\u9519\u7684\u3002\u518d\u770b\u539f\u6570\u636e\u4e5f\u88ab\u6539\u4e3a\u4e86\u201d90\u201c\uff0c\u4e0a\u9762\u4e0d\u662f\u63d0\u5230<strong>map()\u65b9\u6cd5\u751f\u6210\u7684\u662f\u4e00\u4e2a\u65b0\u6d41\uff0c\u539f\u59cb\u6d41\u4e2d\u7684\u6570\u636e\u4e5f\u88ab\u4fee\u6539\u4e86\uff0c\u56e0\u4e3a\u4e0b\u9762\u8fd9\u884c\u4ee3\u7801\u662f\u5728\u539f\u59cb\u6d41\u4e2d\u5143\u7d20\u7684\u57fa\u7840\u4e0a\u4fee\u6539\u7684\u5f15\u7528\u7c7b\u578b\u4e2d\u7684\u6570\u636e\uff0c\u5bfc\u81f4\u7684\u539f\u59cb\u6d41\u4e2d\u7684\u6570\u636e\u4e5f\u4f1a\u6539<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-1024x233.png\" alt=\"\" class=\"wp-image-12513\" width=\"553\" height=\"126\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-1024x233.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-300x68.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-768x175.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-1536x350.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-830x189.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-230x52.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-350x80.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338-480x109.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-338.png 1590w\" sizes=\"(max-width: 553px) 100vw, 553px\" \/><\/figure><\/div>\n\n\n\n<p>map()\u65b9\u6cd5\u7684\u672c\u610f\u662f\u4e0d\u4f1a\u5bf9\u539f\u59cb\u6d41\u4e2d\u7684\u5143\u7d20\u9020\u6210\u5f71\u54cd\uff0c\u90a3\u4e48\u53ea\u8981new\u4e00\u4e2a\u5bf9\u8c61\uff0c\u8fd4\u56de\u5373\u53ef\u4e86\u3002\u73b0\u5728\u60f3\u627e\u51fa\u4e00\u5e74\u7ea7\u5b66\u751f\u7684\u6210\u7ee9\uff0c\u7528map()\u80fd\u5b9e\u73b0\u5417\uff1f<\/p>\n\n\n\n<p><strong>\u56db\u3001\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>java8\u7684stream\u6d41map()\u65b9\u6cd5\u662f\u5c06\u6d41\u4e2d\u7684\u5143\u7d20\u8f6c\u6362\u4e3a\u53e6\u5916\u4e00\u4e2a\u6d41\u4e2d\u7684\u5143\u7d20\uff0c\u8f6c\u6362\u524d\u540e\u4e24\u4e2a\u6d41\u7684\u5143\u7d20\u4e2a\u6570\u4e0d\u53d1\u751f\u6539\u53d8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00 \u5728\u65e5\u5e38\u7684\u5f00\u53d1\u5de5\u4f5c\u4e2d\u7ecf\u5e38\u78b0\u5230\u8981\u5904\u7406list\u4e2d\u6570\u636e\u7684\u95ee\u9898\uff0c\u6bd4\u5982\u4ece\u6570\u636e\u5e93\u4e2d\u67e5\u51fa\u4e86\u5f88\u591a\u5b66\u751f\uff0c\u7531\u4e8e\u4e00\u4e9b\u539f\u56e0\u9700\u8981 [&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\/12507"}],"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=12507"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12507\/revisions"}],"predecessor-version":[{"id":12514,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12507\/revisions\/12514"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}