
{"id":1130,"date":"2020-10-17T17:00:22","date_gmt":"2020-10-17T09:00:22","guid":{"rendered":"https:\/\/www.changxuan.top\/?p=1130"},"modified":"2020-11-29T12:44:16","modified_gmt":"2020-11-29T04:44:16","slug":"java8-stream%e7%9a%84%e7%ae%80%e5%8d%95%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.changxuan.top\/?p=1130","title":{"rendered":"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b"},"content":{"rendered":"<section id=\"nice\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" style=\"font-size: 16px; color: black; padding: 0 10px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;\">\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\n<div class=\"table-of-contents\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<ul style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;\">\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u524d\u8a00<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u793a\u4f8b<\/a>\n<ul style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: square;\">\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u524d\u7f6e\u4ee3\u7801<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u57fa\u672c\u8fc7\u6ee4(filter)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u57fa\u672c\u8f6c\u6362(map)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u53bb\u91cd(distinct)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u6392\u5e8f(sorted)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u533a\u95f4(skip&amp;limit)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u8ba1\u7b97\u603b\u548c(sum)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">flatMap<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u6700\u5927\u6700\u5c0f(min&amp;max)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u6570\u91cf(count)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u5339\u914d(allMatch&amp;anyMatch&amp;noneMatch)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u83b7\u53d6\u5143\u7d20(findFirst&amp;findAny)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u904d\u5386(forEach&amp;forEachOrdered)<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u8f6c\u6362\u6570\u7ec4(toArray)<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 22px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u524d\u8a00<\/span><span class=\"suffix\"><\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u81ea\u4ece Java 8 \u5f00\u59cb\u63d0\u4f9b\u4e86\u4e00\u4e2a<code style=\"font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; color: #1e6bb8; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all;\">Stream<\/code> \u63a5\u53e3\u3002\u56e0\u4e3a\u662f\u4e2a\u65b0\u4e1c\u897f\u5927\u591a\u6570\u540c\u5b66\u53ef\u80fd\u90fd\u6709\u4e9b\u62b5\u89e6\u5fc3\u7406\uff0c\u5f80\u5f80\u5728\u4ee3\u7801\u4e2d\u5e76\u4e0d\u4f1a\u7528\u5230\u5b83\u3002\u8fd9\u6837\u5c31\u4f1a\u5bfc\u81f4\u6709\u4e9b\u5730\u65b9\u7684\u4ee3\u7801\u672c\u8be5\u66f4\u52a0\u7b80\u6d01\uff0c\u800c\u5b9e\u9645\u60c5\u51b5\u786e\u5b9e\u5199\u7684\u5341\u5206\u81c3\u80bf\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u867d\u7136\u6211\u5f88\u8d5e\u6210\u201c\u5199\u5927\u5bb6\u770b\u5f97\u61c2\u7684\u4ee3\u7801\u3002\u201d\u8fd9\u53e5\u8bdd\uff0c\u4f46\u662f\u53c8\u7279\u522b\u559c\u6b22 <code style=\"font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; color: #1e6bb8; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all;\">stream<\/code> \u8fd9\u79cd\u65b9\u5f0f\u3002\u5927\u5bb6\u5728\u9879\u76ee\u4e2d\u591a\u591a\u4f7f\u7528\u81ea\u7136\u4e5f\u5c31\u4f1a\u5341\u5206\u719f\u7ec3\u4e86\u3002<\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 22px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u793a\u4f8b<\/span><span class=\"suffix\"><\/span><\/h2>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u524d\u7f6e\u4ee3\u7801<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-class\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">class<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #458; font-weight: bold; line-height: 26px;\">Student<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">private<\/span>&nbsp;String&nbsp;name;\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">private<\/span>&nbsp;Integer&nbsp;age;\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">Student<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(String&nbsp;name,&nbsp;Integer&nbsp;age)<\/span><\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">this<\/span>.name&nbsp;=&nbsp;name;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">this<\/span>.age&nbsp;=&nbsp;age;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;String&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">getName<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">()<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">return<\/span>&nbsp;name;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">setName<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(String&nbsp;name)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">this<\/span>.name&nbsp;=&nbsp;name;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;Integer&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">getAge<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">()<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">return<\/span>&nbsp;age;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">setAge<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(Integer&nbsp;age)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">this<\/span>.age&nbsp;=&nbsp;age;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-meta\" style=\"color: #999; font-weight: bold; line-height: 26px;\">@Override<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;String&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">toString<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">()<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">return<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"Student{\"<\/span>&nbsp;+\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"name='\"<\/span>&nbsp;+&nbsp;name&nbsp;+&nbsp;<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">'\\''<\/span>&nbsp;+\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\",&nbsp;age=\"<\/span>&nbsp;+&nbsp;age&nbsp;+\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">'}'<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u57fa\u672c\u8fc7\u6ee4(filter)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u57fa\u672c\u8fc7\u6ee4\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">basicFilter<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u57fa\u672c\u8fc7\u6ee4:\u7b5b\u9009\u51fa\u5e74\u9f84\u5927\u4e8e&nbsp;15&nbsp;\u7684\u5b66\u751f<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;Student&gt;&nbsp;above15List&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.filter(s&nbsp;-&gt;&nbsp;s.getAge()&gt;<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">15<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.collect(Collectors.toList());\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">for<\/span>&nbsp;(Student&nbsp;student&nbsp;:&nbsp;above15List)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(student.toString());\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u57fa\u672c\u8f6c\u6362(map)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u57fa\u672c\u8f6c\u6362\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">basicConvert<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u83b7\u53d6\u96c6\u5408\u5185\u6bcf\u4e2a\u5b66\u751f\u7684\u540d\u5b57\u6784\u5efa\u4e00\u4e2a\u65b0\u7684&nbsp;String&nbsp;\u96c6\u5408<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;String&gt;&nbsp;nameList=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.map(Student::getName)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.collect(Collectors.toList());\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">for<\/span>&nbsp;(String&nbsp;name&nbsp;:&nbsp;nameList)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(name);\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u53bb\u91cd(distinct)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u53bb\u91cd\n&nbsp;&nbsp;*&nbsp;\u4f7f\u7528&nbsp;equal&nbsp;\u65b9\u6cd5\u8fdb\u884c\u5224\u65ad\u662f\u5426\u91cd\u590d\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">distinct<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"distinct\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"before\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">for<\/span>&nbsp;(Student&nbsp;student&nbsp;:&nbsp;students)&nbsp;System.out.println(student.toString());\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;Student&gt;&nbsp;noRepeatList&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.distinct()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.collect(Collectors.toList());\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"after\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">for<\/span>&nbsp;(Student&nbsp;student&nbsp;:&nbsp;noRepeatList)&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(student.toString());\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6392\u5e8f(sorted)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\">&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;*&nbsp;\u6392\u5e8f\n&nbsp;&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@description<\/span>&nbsp;comparing&nbsp;\u9ed8\u8ba4\u4e3a\u5347\u5e8f\u6392\u5217\uff0c&nbsp;reversed&nbsp;\u5219\u4e3a\u964d\u5e8f\u6392\u5217\n&nbsp;&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">sort<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u9996\u5148\u6839\u636e\u5b66\u751f\u5e74\u9f84\u6392\u5e8f\uff0c\u5e74\u9f84\u76f8\u540c\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u59d3\u540d\u6392\u5e8f<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"\u6392\u5e8f\uff08sorted\uff09\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;Student&gt;&nbsp;sortedList&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sorted(Comparator.comparing(Student::getAge)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.reversed().thenComparing(Student::getName))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.collect(Collectors.toList());\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">for<\/span>&nbsp;(Student&nbsp;student&nbsp;:&nbsp;sortedList)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(student.toString());\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u533a\u95f4(skip&amp;limit)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;skip&nbsp;and&nbsp;limit\n&nbsp;&nbsp;*&nbsp;skip&nbsp;:&nbsp;\u8df3\u8fc7&nbsp;n&nbsp;\u4e2a\u5143\u7d20\uff0c\u4ece&nbsp;1&nbsp;\u5f00\u59cb\u8ba1\u6570\u3002\n&nbsp;&nbsp;*&nbsp;limit&nbsp;:&nbsp;\u6b64\u6b21\u53d6\u7684\u5143\u7d20\u6570\u91cf\u3002\n&nbsp;&nbsp;*&nbsp;ex.&nbsp;skip(1).limit(2)&nbsp;\u8df3\u8fc7\u7b2c\u4e00\u4e2a\uff0c\u53d6\u51fa\u7b2c\u4e8c\u3001\u7b2c\u4e09\u4e2a\u5143\u7d20\u3002\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">skipAndLimit<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"Skip&nbsp;And&nbsp;Limit\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;Student&gt;&nbsp;partOfStudent&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sorted(Comparator.comparing(Student::getAge)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.reversed())\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.skip(<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">1<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.limit(<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">2<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.collect(Collectors.toList());\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">for<\/span>&nbsp;(Student&nbsp;student&nbsp;:&nbsp;partOfStudent)&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(student.toString());\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u8ba1\u7b97\u603b\u548c(sum)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u8ba1\u7b97\u603b\u548c\n&nbsp;&nbsp;*&nbsp;\u5176\u5b83\uff1a&nbsp;mapToDouble\u3001mapToInt\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">mapToLong<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8ba1\u7b97\u96c6\u5408\u4e2d\u6240\u6709\u5b66\u751f\u5e74\u9f84\u7684\u603b\u548c<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"mapToLong\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;Long&nbsp;ageSum&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.mapToLong(Student::getAge)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sum();\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(ageSum);\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">flatMap<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;flatMap\n&nbsp;&nbsp;*&nbsp;\u63a5\u6536\u4e00\u4e2a\u51fd\u6570&nbsp;Mapper\uff0c&nbsp;\u5bf9\u6d41\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\uff0cmapper&nbsp;\u4f1a\u5c06\u8be5\u5143\u7d20\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6d41&nbsp;Stream&nbsp;\uff0c\u7136\u540e\u628a\u65b0\u751f\u6210\u6d41\n&nbsp;&nbsp;*&nbsp;\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u4f20\u9012\u4e2a\u4e0b\u4e00\u4e2a\u64cd\u4f5c\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">flatMap<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"flatMap\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;String&gt;&nbsp;lines&nbsp;=&nbsp;Arrays.asList(<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">new<\/span>&nbsp;String[]{<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"abc&nbsp;DEF\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"hhhh\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"fire\"<\/span>});\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;String&gt;&nbsp;words&nbsp;=&nbsp;lines.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.flatMap(line&nbsp;-&gt;&nbsp;Arrays.stream(line.split(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"&nbsp;\"<\/span>)))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.collect(Collectors.toList());\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(words);\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6700\u5927\u6700\u5c0f(min&amp;max)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;min&nbsp;and&nbsp;max\n&nbsp;&nbsp;*&nbsp;min&nbsp;and&nbsp;max&nbsp;method&nbsp;will&nbsp;return&nbsp;a&nbsp;Optional&lt;T&gt;&nbsp;Object&nbsp;that&nbsp;include&nbsp;some&nbsp;methods&nbsp;such&nbsp;as&nbsp;get,isPresent&nbsp;and&nbsp;so&nbsp;on.\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;student&nbsp;Collection\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">minAndMax<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u83b7\u53d6\u5e74\u9f84\u6700\u5927\u548c\u6700\u5c0f\u5e74\u9f84\u7684\u5b66\u751f<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"min&nbsp;and&nbsp;max\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;Student&nbsp;min&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.min(Comparator.comparing(Student::getAge))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.get();\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"min:\"<\/span>+min.toString());\n&nbsp;&nbsp;&nbsp;&nbsp;Student&nbsp;max&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.max(Comparator.comparing(Student::getAge))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.get();\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"max\"<\/span>+max.toString());\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6570\u91cf(count)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u7b26\u5408\u6761\u4ef6\u7684\u5143\u7d20\u6570\u91cf&nbsp;count\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;student&nbsp;collection\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">count<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"count\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">long<\/span>&nbsp;above15Students&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.filter(student&nbsp;-&gt;&nbsp;student.getAge()&nbsp;&gt;&nbsp;<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">15<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.count();\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"\u5e74\u9f84\u5927\u4e8e15\u7684\u5b66\u751f\u6570\u91cf\uff1a\"<\/span>+above15Students);\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u5339\u914d(allMatch&amp;anyMatch&amp;noneMatch)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u5224\u65ad\u6d41\u4e2d\u7684\u5143\u7d20\u662f\u5426\u6ee1\u8db3\u67d0\u4e00\u6761\u4ef6\n&nbsp;&nbsp;*&nbsp;allMatch:&nbsp;\u5f53\u6d41\u4e2d\u7684\u6240\u6709\u5143\u7d20\u90fd\u6ee1\u8db3\u6761\u4ef6\u65f6\u624d\u8fd4\u56de&nbsp;true\n&nbsp;&nbsp;*&nbsp;anyMatch:&nbsp;\u53ea\u8981\u6d41\u4e2d\u6709\u4e00\u4e2a\u5143\u7d20\u6ee1\u8db3\u6761\u4ef6\u5c31\u8fd4\u56de&nbsp;true\n&nbsp;&nbsp;*&nbsp;noneMatch:&nbsp;\u53ea\u6709\u6d41\u4e2d\u7684\u6240\u6709\u5143\u7d20\u90fd\u4e0d\u6ee1\u8db3\u6761\u4ef6\u624d\u8fd4\u56de&nbsp;true\n&nbsp;&nbsp;*&nbsp;\u5982\u679c\u6d41\u4e3a\u7a7a\uff0c\u90a3\u4e48\u90fd\u5c06\u8fd4\u56de&nbsp;true\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">match<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"match\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u5224\u65ad\u662f\u5426\u6240\u6709\u7684\u5b66\u751f\u5e74\u9f84\u90fd\u5927\u4e8e&nbsp;8&nbsp;\u5c81,&nbsp;\u9884\u671f\u8f93\u51fa\u4e3a&nbsp;true<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">boolean<\/span>&nbsp;allMatch&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.allMatch(student&nbsp;-&gt;&nbsp;student.getAge()&nbsp;&gt;&nbsp;<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">8<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(allMatch);\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u5224\u65ad\u662f\u5426\u6709\u5b66\u751f\u5e74\u9f84\u5927\u4e8e&nbsp;15&nbsp;\u5c81\uff0c\u9884\u671f\u8f93\u51fa\u4e3a&nbsp;true<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">boolean<\/span>&nbsp;anyMatch&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.anyMatch(student&nbsp;-&gt;&nbsp;student.getAge()&nbsp;&gt;&nbsp;<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">15<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(anyMatch);\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u5224\u65ad\u662f\u5426\u6709\u5b66\u751f\u5e74\u9f84\u5927\u4e8e&nbsp;30&nbsp;\u5c81\uff0c\u9884\u671f\u8f93\u51fa\u4e3a&nbsp;true<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">boolean<\/span>&nbsp;noneMatch&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.noneMatch(student&nbsp;-&gt;&nbsp;student.getAge()&nbsp;&gt;&nbsp;<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">30<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(noneMatch);\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u83b7\u53d6\u5143\u7d20(findFirst&amp;findAny)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;find&nbsp;first&nbsp;and&nbsp;find&nbsp;any\n&nbsp;&nbsp;*&nbsp;\u83b7\u53d6\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u83b7\u53d6\u4efb\u610f\u4e00\u5143\u7d20\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">findFirstAndAny<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"findFirst&nbsp;and&nbsp;findAny\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;Student&nbsp;firstStudent&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.findFirst()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.get();\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(firstStudent.toString());\n&nbsp;&nbsp;&nbsp;&nbsp;Student&nbsp;anyStudent&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.filter(student&nbsp;-&gt;&nbsp;student.getAge()&nbsp;&lt;&nbsp;<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">15<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.findAny()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.get();\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(anyStudent.toString());\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u904d\u5386(forEach&amp;forEachOrdered)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u904d\u5386\n&nbsp;&nbsp;*&nbsp;forEach&nbsp;\u4e0d\u4fdd\u8bc1\u5904\u7406\u7684\u987a\u5e8f\n&nbsp;&nbsp;*&nbsp;forEachOrdered&nbsp;\u4fdd\u8bc1\u6309\u7167\u6d41\u4e2d\u5143\u7d20\u7684\u51fa\u73b0\u987a\u5e8f\u8fdb\u884c\u5904\u7406\n&nbsp;&nbsp;*&nbsp;\u5b83\u4eec\u63a5\u53d7\u4e00\u4e2a&nbsp;Consumer&nbsp;\u5bf9\u8c61\uff0c\u5bf9\u6d41\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u4f20\u9012\u7ed9&nbsp;Consumer\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">forEach<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"ForEach\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.forEach(student&nbsp;-&gt;&nbsp;System.out.println(student.toString()));\n&nbsp;&nbsp;&nbsp;&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.forEach(student&nbsp;-&gt;&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(student.getName());;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(student.toString());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\n&nbsp;&nbsp;&nbsp;&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.forEach(System.out::println);\n}\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u8f6c\u6362\u6570\u7ec4(toArray)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/www.changxuan.top\/wp-content\/uploads\/2020\/11\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #f8f8f8; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #333; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #f8f8f8; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #998; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;*&nbsp;\u5c06\u6d41\u8f6c\u6362\u6570\u7ec4\n&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #d14; line-height: 26px;\">@param<\/span>&nbsp;students&nbsp;\u5b66\u751f\u96c6\u5408\n&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;\n<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">static<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #900; font-weight: bold; line-height: 26px;\">toArray<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(List&lt;Student&gt;&nbsp;students)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #d14; line-height: 26px;\">\"toArray\"<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;Student[]&nbsp;above15Students&nbsp;=&nbsp;students.stream()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.filter(student&nbsp;-&gt;&nbsp;student.getAge()&nbsp;&gt;&nbsp;<span class=\"hljs-number\" style=\"color: #008080; line-height: 26px;\">15<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.toArray(Student[]::<span class=\"hljs-keyword\" style=\"color: #333; font-weight: bold; line-height: 26px;\">new<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(Arrays.toString(above15Students));\n}\n<\/code><\/pre>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u793a\u4f8b \u524d\u7f6e\u4ee3\u7801 \u57fa\u672c\u8fc7\u6ee4(filter) \u57fa\u672c\u8f6c\u6362(map) \u53bb\u91cd(distinct) \u6392\u5e8f(sorte &hellip; <a href=\"https:\/\/www.changxuan.top\/?p=1130\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,54],"tags":[92],"class_list":["post-1130","post","type-post","status-publish","format-standard","hentry","category-tech","category-54","tag-stream"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b - \u5e38\u8f69<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.changxuan.top\/?p=1130\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b - \u5e38\u8f69\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00 \u793a\u4f8b \u524d\u7f6e\u4ee3\u7801 \u57fa\u672c\u8fc7\u6ee4(filter) \u57fa\u672c\u8f6c\u6362(map) \u53bb\u91cd(distinct) \u6392\u5e8f(sorte &hellip; \u7ee7\u7eed\u9605\u8bfbJava8 Stream\u7684\u7b80\u5355\u793a\u4f8b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.changxuan.top\/?p=1130\" \/>\n<meta property=\"og:site_name\" content=\"\u5e38\u8f69\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-17T09:00:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-29T04:44:16+00:00\" \/>\n<meta name=\"author\" content=\"\u5e38\u8f69\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5e38\u8f69\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=1130#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=1130\"},\"author\":{\"name\":\"\u5e38\u8f69\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\"},\"headline\":\"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b\",\"datePublished\":\"2020-10-17T09:00:22+00:00\",\"dateModified\":\"2020-11-29T04:44:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=1130\"},\"wordCount\":53,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\"},\"keywords\":[\"Stream\"],\"articleSection\":[\"\u6280\u672f\",\"\u6559\u7a0b\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.changxuan.top\\\/?p=1130#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=1130\",\"url\":\"https:\\\/\\\/www.changxuan.top\\\/?p=1130\",\"name\":\"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b - \u5e38\u8f69\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#website\"},\"datePublished\":\"2020-10-17T09:00:22+00:00\",\"dateModified\":\"2020-11-29T04:44:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=1130#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.changxuan.top\\\/?p=1130\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=1130#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/www.changxuan.top\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#website\",\"url\":\"https:\\\/\\\/www.changxuan.top\\\/\",\"name\":\"\u5e38\u8f69\",\"description\":\"\u95fb\u9053\u6709\u5148\u540e\uff0c\u672f\u4e1a\u6709\u4e13\u653b-\u4e00\u4e8c\u4e09\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.changxuan.top\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\",\"name\":\"\u5e38\u8f69\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\",\"url\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\",\"contentUrl\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\",\"width\":960,\"height\":960,\"caption\":\"\u5e38\u8f69\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\"},\"description\":\"\u603b\u8981\u505a\u70b9\u4ec0\u4e48\u5427\uff01\",\"sameAs\":[\"https:\\\/\\\/www.changxuan.top\"],\"url\":\"https:\\\/\\\/www.changxuan.top\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b - \u5e38\u8f69","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.changxuan.top\/?p=1130","og_locale":"zh_CN","og_type":"article","og_title":"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b - \u5e38\u8f69","og_description":"\u524d\u8a00 \u793a\u4f8b \u524d\u7f6e\u4ee3\u7801 \u57fa\u672c\u8fc7\u6ee4(filter) \u57fa\u672c\u8f6c\u6362(map) \u53bb\u91cd(distinct) \u6392\u5e8f(sorte &hellip; \u7ee7\u7eed\u9605\u8bfbJava8 Stream\u7684\u7b80\u5355\u793a\u4f8b","og_url":"https:\/\/www.changxuan.top\/?p=1130","og_site_name":"\u5e38\u8f69","article_published_time":"2020-10-17T09:00:22+00:00","article_modified_time":"2020-11-29T04:44:16+00:00","author":"\u5e38\u8f69","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5e38\u8f69","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.changxuan.top\/?p=1130#article","isPartOf":{"@id":"https:\/\/www.changxuan.top\/?p=1130"},"author":{"name":"\u5e38\u8f69","@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd"},"headline":"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b","datePublished":"2020-10-17T09:00:22+00:00","dateModified":"2020-11-29T04:44:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.changxuan.top\/?p=1130"},"wordCount":53,"commentCount":0,"publisher":{"@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd"},"keywords":["Stream"],"articleSection":["\u6280\u672f","\u6559\u7a0b"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.changxuan.top\/?p=1130#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.changxuan.top\/?p=1130","url":"https:\/\/www.changxuan.top\/?p=1130","name":"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b - \u5e38\u8f69","isPartOf":{"@id":"https:\/\/www.changxuan.top\/#website"},"datePublished":"2020-10-17T09:00:22+00:00","dateModified":"2020-11-29T04:44:16+00:00","breadcrumb":{"@id":"https:\/\/www.changxuan.top\/?p=1130#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.changxuan.top\/?p=1130"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.changxuan.top\/?p=1130#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.changxuan.top\/"},{"@type":"ListItem","position":2,"name":"Java8 Stream\u7684\u7b80\u5355\u793a\u4f8b"}]},{"@type":"WebSite","@id":"https:\/\/www.changxuan.top\/#website","url":"https:\/\/www.changxuan.top\/","name":"\u5e38\u8f69","description":"\u95fb\u9053\u6709\u5148\u540e\uff0c\u672f\u4e1a\u6709\u4e13\u653b-\u4e00\u4e8c\u4e09","publisher":{"@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.changxuan.top\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd","name":"\u5e38\u8f69","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg","url":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg","contentUrl":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg","width":960,"height":960,"caption":"\u5e38\u8f69"},"logo":{"@id":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg"},"description":"\u603b\u8981\u505a\u70b9\u4ec0\u4e48\u5427\uff01","sameAs":["https:\/\/www.changxuan.top"],"url":"https:\/\/www.changxuan.top\/?author=1"}]}},"views":1421,"_links":{"self":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts\/1130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1130"}],"version-history":[{"count":10,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts\/1130\/revisions"}],"predecessor-version":[{"id":1193,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts\/1130\/revisions\/1193"}],"wp:attachment":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}