{"id":12804,"date":"2023-09-22T13:30:46","date_gmt":"2023-09-22T05:30:46","guid":{"rendered":"https:\/\/92it.top\/?p=12804"},"modified":"2023-09-22T13:30:46","modified_gmt":"2023-09-22T05:30:46","slug":"java8-stream%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=12804","title":{"rendered":"Java8 Stream\u5165\u95e8"},"content":{"rendered":"\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\/09\/\u56fe\u7247-38-1024x572.png\" alt=\"\" class=\"wp-image-12805\" width=\"481\" height=\"269\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38-1024x572.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38-300x167.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38-768x429.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38-830x463.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38-230x128.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38-350x195.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38-480x268.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-38.png 1236w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/figure><\/div>\n\n\n\n<p>\u8bf4\u8d77\u6d41\uff0c\u6211\u4eec\u4f1a\u60f3\u8d77\u624b\u673a \uff0c\u7535\u8111\u7ec4\u88c5\u6d41\u6c34\u7ebf\uff0c\u7269\u6d41\u4ed3\u5e93\u5546\u54c1\u5305\u88c5\u6d41\u6c34\u7ebf\u7b49\u7b49\u3002\u5982\u679c\u628a\u624b\u673a ,\u7535\u8111,\u5305\u88f9\u770b\u505a\u6700\u7ec8\u7ed3\u679c\u7684\u8bdd,\u90a3\u4e48\u52a0\u5de5\u5546\u54c1\u524d\u7684\u5404\u79cd\u96f6\u90e8\u4ef6\u5c31\u53ef\u4ee5\u770b\u505a\u6570\u636e\u6e90\uff0c\u800c\u4e2d\u95f4\u4e00\u7cfb\u5217\u7684\u52a0\u5de5\u4f5c\u4e1a\u64cd\u4f5c\uff0c\u5c31\u53ef\u4ee5\u770b\u505a\u6d41\u7684\u5904\u7406\u3002<\/p>\n\n\n\n<p><strong>\u6d41\u7684\u6982\u5ff5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Java Se\u4e2d\u5bf9\u4e8e\u6d41\u7684\u64cd\u4f5c\u6709\u8f93\u5165\u8f93\u51faIO\u6d41,\u800cJava8\u4e2d\u5f15\u5165\u7684Stream \u5c5e\u4e8eJava API\u4e2d\u7684\u4e00\u4e2a\u65b0\u6210\u5458\uff0c\u5b83\u5141\u8bb8\u4f60\u4ee5\u58f0\u660e\u6027\u65b9\u5f0f\u5904\u7406\u6570\u636e\u96c6\u5408\uff0cStream \u4f7f\u7528\u4e00\u79cd\u7c7b\u4f3c SQL \u8bed\u53e5\u4ece\u6570\u636e\u5e93\u67e5\u8be2\u6570\u636e\u7684\u76f4\u89c2\u65b9\u5f0f\u6765\u63d0\u4f9b\u4e00\u79cd\u5bf9 Java \u96c6\u5408\u8fd0\u7b97\u548c\u8868\u8fbe\u7684\u9ad8\u9636\u62bd\u8c61\u3002 \u6ce8\u610f\u8fd9\u91cc\u7684\u6d41\u64cd\u4f5c\u53ef\u4ee5\u770b\u505a\u662f\u5bf9\u96c6\u5408\u6570\u636e\u7684\u5904\u7406\u3002<\/p>\n\n\n\n<p>\u7b80\u5355\u6765\u8bf4,\u6d41\u662f\u4e00\u79cd\u6570\u636e\u6e20\u9053,\u7528\u4e8e\u64cd\u4f5c\u6570\u636e\u6e90(\u96c6\u5408\u3001\u6570\u7ec4\u3001\u6587\u4ef6\u7b49)\u6240\u751f\u4ea7\u7684\u5143\u7d20\u5e8f\u5217\u3002<\/p>\n\n\n\n<ul><li>\u6e90-\u6d41\u4f1a\u4f7f\u7528\u4e00\u4e2a\u63d0\u4f9b\u6570\u636e\u7684\u6e90,\u5982\u96c6\u5408\u3001\u6570\u7ec4\u6216\u8f93\u5165|\u8f93\u51fa\u8d44\u6e90\u3002 <\/li><\/ul>\n\n\n\n<p>\u4ece\u6709\u5e8f\u96c6\u751f\u6210\u6d41\u65f6\u4f1a\u4fdd\u7559\u539f\u6709\u7684\u987a\u5e8f\u3002\u7531\u5217\u8868\u751f\u6210\u7684\u6d41\uff0c\u5176\u5143\u7d20\u987a\u5e8f\u4e0e\u5217\u8868\u4e00\u81f4<\/p>\n\n\n\n<ul><li>\u5143\u7d20\u5e8f\u5217-\u5c31\u50cf\u96c6\u5408\u4e00\u6837\uff0c\u6d41\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u63a5\u53e3,\u53ef\u4ee5\u8bbf\u95ee\u7279\u5b9a\u5143\u7d20\u7c7b\u578b\u7684\u4e00\u7ec4\u6709\u5e8f\u503c\u3002<\/li><li>\u6570\u636e\u5904\u7406\u64cd\u4f5c-\u6d41\u7684\u6570\u636e\u5904\u7406\u529f\u80fd\u652f\u6301\u7c7b\u4f3c\u4e8e\u6570\u636e\u5e93\u7684\u64cd\u4f5c(\u6570\u636e\u7b5b\u9009\u3001\u8fc7\u6ee4\u3001\u6392\u5e8f\u7b49\u64cd\u4f5c)\u3002<\/li><li>\u6d41\u6c34\u7ebf-\u591a\u4e2a\u6d41\u64cd\u4f5c\u672c\u8eab\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6d41\uff0c\u591a\u4e2a\u64cd\u4f5c\u5c31\u53ef\u4ee5\u94fe\u63a5\u8d77\u6765,\u6210\u4e3a\u6570\u636e\u5904\u7406\u7684\u4e00\u9053\u6d41\u6c34\u7ebf\u3002<\/li><\/ul>\n\n\n\n<p><strong>\u6d41&amp;\u96c6\u5408<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ul><li>\u8ba1\u7b97\u7684\u65f6\u671f <\/li><\/ul>\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\/09\/\u56fe\u7247-39-1024x693.png\" alt=\"\" class=\"wp-image-12806\" width=\"484\" height=\"327\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39-1024x693.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39-300x203.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39-768x520.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39-830x562.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39-230x156.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39-350x237.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39-480x325.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-39.png 1270w\" sizes=\"(max-width: 484px) 100vw, 484px\" \/><\/figure><\/div>\n\n\n\n<p>\u96c6\u5408\u4e2d\u6570\u636e\u90fd\u662f\u8ba1\u7b97\u5b8c\u6bd5\u7684\u6570\u636e\uff0c\u4f8b\u5982\u4ece\u6570\u636e\u5e93\u4e2d\u67e5\u8be2\u7528\u6237\u8bb0\u5f55 \u6309\u7528\u6237id \u67e5\u8be2 \u964d\u5e8f\u6392\u5217 \u7136\u540e\u901a\u8fc7list \u63a5\u6536\u7528\u6237\u8bb0\u5f55\uff0c\u6570\u636e\u7684\u8ba1\u7b97\u5df2\u5728\u653e\u5165\u96c6\u5408\u524d\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>\u6d41\u4e2d\u6570\u636e\u6309\u9700\u8ba1\u7b97\uff0c\u6309\u7167\u4f7f\u7528\u8005\u7684\u9700\u8981\u8ba1\u7b97\u6570\u636e\uff0c\u4f8b\u5982\u901a\u8fc7\u641c\u7d22\u5f15\u64ce\u8fdb\u884c\u641c\u7d22\uff0c\u641c\u7d22\u51fa\u6765\u7684\u6761\u76ee\u5e76\u4e0d\u662f\u5168\u90e8\u5448\u73b0\u51fa\u6765\u7684\uff0c\u800c\u4e14\u5148\u663e\u793a\u6700\u7b26\u5408\u7684\u524d 10 \u6761\u6216\u8005\u524d 20 \u6761\uff0c\u53ea\u6709\u5728\u70b9\u51fb \u201c\u4e0b\u4e00\u9875\u201d \u7684\u65f6\u5019\uff0c\u624d\u4f1a\u518d\u8f93\u51fa\u65b0\u7684 10 \u6761\u3002\u6d41\u7684\u8ba1\u7b97\u4e5f\u662f\u8fd9\u6837\uff0c\u5f53\u7528\u6237\u9700\u8981\u5bf9\u5e94\u6570\u636e\u65f6\uff0cStream \u624d\u4f1a\u5bf9\u5176\u8fdb\u884c\u8ba1\u7b97\u5904\u7406\u3002 <\/p>\n\n\n\n<ul><li>\u5916\u90e8\u8fed\u4ee3\u4e0e\u5185\u90e8\u8fed\u4ee3 <\/li><\/ul>\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\/09\/\u56fe\u7247-40-1024x231.png\" alt=\"\" class=\"wp-image-12807\" width=\"638\" height=\"144\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40-1024x231.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40-300x68.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40-768x173.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40-830x187.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40-230x52.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40-350x79.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40-480x108.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-40.png 1260w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/figure><\/div>\n\n\n\n<p>\u628a\u96c6\u5408\u6bd4\u4f5c\u4e00\u4e2a\u5de5\u5382\u7684\u4ed3\u5e93\u7684\u8bdd\uff0c\u4e00\u5f00\u59cb\u5de5\u5382\u786c\u4ef6\u6bd4\u8f83\u843d\u540e\uff0c\u8981\u5bf9\u8d27\u7269\u4f5c\u4ec0\u4e48\u4fee\u6539\uff0c\u6b64\u65f6\u5de5\u4eba\u4eb2\u81ea\u8d70\u8fdb\u4ed3\u5e93\u5bf9\u8d27\u7269\u8fdb\u884c\u5904\u7406\uff0c\u6709\u65f6\u5019\u8fd8\u8981\u5c06\u5904\u7406\u540e\u7684\u8d27\u7269\u8f6c\u8fd0\u5230\u53e6\u4e00\u4e2a\u4ed3\u5e93\u4e2d\u3002\u6b64\u65f6\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\u9700\u8981\u4eb2\u81ea\u53bb\u505a\u8fed\u4ee3\uff0c\u4e00\u4e2a\u4e2a\u5730\u627e\u5230\u9700\u8981\u7684\u8d27\u7269\uff0c\u5e76\u8fdb\u884c\u5904\u7406\uff0c\u8fd9\u53eb\u505a\u5916\u90e8\u8fed\u4ee3\u3002<\/p>\n\n\n\n<p>\u5f53\u5de5\u5382\u53d1\u5c55\u8d77\u6765\u540e\uff0c\u914d\u5907\u4e86\u6d41\u6c34\u7ebf\u4f5c\u4e1a\uff0c\u5de5\u5382\u53ea\u8981\u6839\u636e\u9700\u6c42\u8bbe\u8ba1\u51fa\u76f8\u5e94\u7684\u6d41\u6c34\u7ebf\uff0c\u7136\u540e\u5de5\u4eba\u53ea\u8981\u628a\u8d27\u7269\u653e\u5230\u6d41\u6c34\u7ebf\u4e0a\uff0c\u5c31\u53ef\u4ee5\u7b49\u7740\u63a5\u6536\u6210\u679c\u4e86\uff0c\u800c\u4e14\u6d41\u6c34\u7ebf\u8fd8\u53ef\u4ee5\u6839\u636e\u8981\u6c42\u76f4\u63a5\u628a\u8d27\u7269\u8f93\u9001\u5230\u76f8\u5e94\u7684\u4ed3\u5e93\u3002<\/p>\n\n\n\n<p>\u8fd9\u5c31\u53eb\u505a\u5185\u90e8\u8fed\u4ee3\uff0c\u6d41\u6c34\u7ebf\u5df2\u7ecf\u5e2e\u4f60\u628a\u8fed\u4ee3\u7ed9\u5b8c\u6210\u4e86\uff0c\u4f60\u53ea\u9700\u8981\u8bf4\u8981\u5e72\u4ec0\u4e48\u5c31\u53ef\u4ee5\u4e86\uff08\u5373\u8bbe\u8ba1\u51fa\u5408\u7406\u7684\u6d41\u6c34\u7ebf\uff09\u3002\u76f8\u5f53\u4e8e Java8 \u5f15\u5165\u7684Stream \u5bf9\u6570\u636e\u7684\u5904\u7406\u5b9e\u73b0\u4e86\u201d\u81ea\u52a8\u5316\u201d\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p><strong>\u6d41\u64cd\u4f5c\u8fc7\u7a0b<\/strong> <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41.png\" alt=\"\" class=\"wp-image-12808\" width=\"499\" height=\"100\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41.png 950w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41-300x61.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41-768x155.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41-830x168.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41-230x46.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41-350x71.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-41-480x97.png 480w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/figure><\/div>\n\n\n\n<p>\u6574\u4e2a\u6d41\u64cd\u4f5c\u5c31\u662f\u4e00\u6761\u6d41\u6c34\u7ebf\uff0c\u5c06\u5143\u7d20\u653e\u5728\u6d41\u6c34\u7ebf\u4e0a\u4e00\u4e2a\u4e2a\u5730\u8fdb\u884c\u5904\u7406\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f:\u5f88\u591a\u6d41\u64cd\u4f5c\u672c\u8eab\u5c31\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6d41\uff0c\u6240\u4ee5\u591a\u4e2a\u64cd\u4f5c\u53ef\u4ee5\u76f4\u63a5\u8fde\u63a5\u8d77\u6765\uff0c \u5982\u4e0b\u56fe\u8fd9\u6837\uff0c\u64cd\u4f5c\u53ef\u4ee5\u8fdb\u884c\u94fe\u5f0f\u8c03\u7528\uff0c\u5e76\u4e14\u5e76\u884c\u6d41\u8fd8\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u6d41\u5e76\u884c\u5904\u7406\u64cd\u4f5c\u3002 <\/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\/09\/\u56fe\u7247-42-1024x227.png\" alt=\"\" class=\"wp-image-12809\" width=\"539\" height=\"119\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42-1024x227.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42-300x67.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42-768x171.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42-830x184.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42-230x51.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42-350x78.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42-480x107.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-42.png 1288w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/figure><\/div>\n\n\n\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u6d41\u64cd\u4f5c\u8fc7\u7a0b\u5206\u4e3a\u4e09\u4e2a\u9636\u6bb5:<\/p>\n\n\n\n<ul><li>\u521b\u5efa<\/li><\/ul>\n\n\n\n<p>\u501f\u52a9\u6570\u636e\u6e90\u521b\u5efa\u6d41\u5bf9\u8c61<\/p>\n\n\n\n<ul><li>\u4e2d\u95f4\u5904\u7406<\/li><\/ul>\n\n\n\n<p>\u7b5b\u9009\u3001\u5207\u7247\u3001\u6620\u5c04\u3001\u6392\u5e8f\u7b49\u4e2d\u95f4\u64cd\u4f5c<\/p>\n\n\n\n<ul><li>\u7ec8\u6b62\u6d41<\/li><\/ul>\n\n\n\n<p>\u5339\u914d\u3001\u6c47\u603b\u3001\u5206\u7ec4\u7b49\u7ec8\u6b62\u64cd\u4f5c<\/p>\n\n\n\n<p><strong>\u6d41\u7684\u521b\u5efa<\/strong> <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5bf9\u6d41\u64cd\u4f5c\u9996\u5148\u8981\u521b\u5efa\u5bf9\u5e94\u7684\u6d41\uff0c\u6d41\u7684\u521b\u5efa\u96c6\u4e2d\u5f62\u5f0f\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\/09\/\u56fe\u7247-43-1024x432.png\" alt=\"\" class=\"wp-image-12810\" width=\"497\" height=\"209\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43-1024x432.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43-300x127.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43-768x324.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43-830x350.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43-230x97.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43-350x148.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43-480x203.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-43.png 1280w\" sizes=\"(max-width: 497px) 100vw, 497px\" \/><\/figure><\/div>\n\n\n\n<p><strong>1 \u96c6\u5408\u521b\u5efa\u6d41 <\/strong><\/p>\n\n\n\n<p>\u5728 Java 8 \u4e2d, \u96c6\u5408\u63a5\u53e3\u6709\u4e24\u4e2a\u65b9\u6cd5\u6765\u751f\u6210\u6d41\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">stream() \u2212 \u4e3a\u96c6\u5408\u521b\u5efa\u4e32\u884c\u6d41\u3002\n\nparallelStream() \u2212 \u4e3a\u96c6\u5408\u521b\u5efa\u5e76\u884c\u6d41\u3002<\/pre>\n\n\n\n<p>\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b: <\/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 static void main(String[] args) {\n    \/**\n         * \u5b9a\u4e49\u96c6\u5408l1 \u5e76\u4e3a\u96c6\u5408\u521b\u5efa\u4e32\u884c\u6d41\n         *\/\n    List&lt;String> l1 = Arrays.asList(\"\u5468\u661f\u9a70\", \"\u5468\u6770\u4f26\", \"\u5468\u661f\u661f\", \"\u5468\u6da6\u53d1\");\n    \/\/ \u8fd4\u56de\u4e32\u884c\u6d41\n    l1.stream();\n    \/\/ \u8fd4\u56de\u5e76\u884c\u6d41\n    l1.parallelStream();\n} <\/pre>\n\n\n\n<p>\u4e0a\u8ff0\u64cd\u4f5c\u5f97\u5230\u7684\u6d41\u662f\u901a\u8fc7\u539f\u59cb\u6570\u636e\u8f6c\u6362\u8fc7\u6765\u7684\u6d41\uff0c\u9664\u4e86\u8fd9\u79cd\u6d41\u521b\u5efa\u7684\u57fa\u672c\u64cd\u4f5c\u5916\uff0c\u5bf9\u4e8e\u6d41\u7684\u521b\u5efa\u8fd8\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p><strong>2 \u503c\u521b\u5efa\u6d41 <\/strong><\/p>\n\n\n\n<p>Stream.of(T\u2026) \uff1a Stream.of(&#8220;aa&#8221;, &#8220;bb&#8221;) \u751f\u6210\u6d41<\/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=\"\">Stream stream = Stream.of(\"java8\", \"Spring\", \"SpringCloud\");\nstream.forEach(System.out::println); <\/pre>\n\n\n\n<p><strong>3 \u6570\u7ec4\u521b\u5efa\u6d41<\/strong> <\/p>\n\n\n\n<p>\u6839\u636e\u53c2\u6570\u7684\u6570\u7ec4\u7c7b\u578b\u521b\u5efa\u5bf9\u5e94\u7684\u6d41\u3002<\/p>\n\n\n\n<ul><li>Arrays.stream(T[ ])<\/li><li>Arrays.stream(int[ ])<\/li><li>Arrays.stream(double[ ])<\/li><li>Arrays.stream(long[ ]) <\/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=\"\"> \/**\n * \u8fd9\u91cc\u4ee5int \u4e3a\u4f8b   long double \u4e0d\u518d\u4e3e\u4f8b\n *\/\n Stream stream = Arrays.stream(Arrays.asList(10, 20, 30, 40).toArray());\n \/\/ \u6839\u636e\u6570\u7ec4\u7d22\u5f15\u8303\u56f4\u521b\u5efa\u6307\u5b9aStream\n stream = Arrays.stream(Arrays.asList(10, 20, 30, 40).toArray(), 0, 2); <\/pre>\n\n\n\n<p><strong>4 \u6587\u4ef6\u751f\u6210\u6d41 <\/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=\"\">stream = Files.lines(Paths.get(\"C:\\\\java\\\\jdbc.properties\"));\nSystem.out.println(stream.collect(Collectors.toList()));\n\/\/ \u6307\u5b9a\u5b57\u7b26\u96c6\u7f16\u7801\nstream = Files.lines(Paths.get(\"C:\\\\java\\\\jdbc.properties\"), Charset.forName(\"utf-8\"));\nSystem.out.println(stream.collect(Collectors.toList())); <\/pre>\n\n\n\n<p><strong>5 \u51fd\u6570\u751f\u6210\u6d41 <\/strong><\/p>\n\n\n\n<p>\u4e24\u4e2a\u65b9\u6cd5\uff1a <\/p>\n\n\n\n<ul><li>iterate \uff1a \u4f9d\u6b21\u5bf9\u6bcf\u4e2a\u65b0\u751f\u6210\u7684\u503c\u5e94\u7528\u51fd\u6570<\/li><li>generate \uff1a\u63a5\u53d7\u4e00\u4e2a\u51fd\u6570\uff0c\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u503c<\/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=\"\">\/\/ \u91cd100 \u5f00\u59cb \u751f\u6210\u5076\u6570\u6d41\n Stream.iterate(100, n -> n + 2);\n \/\/ \u4ea7\u751f1-100 \u968f\u673a\u6570\n Stream.generate(() ->(int) (Math.random() * 100 + 1)); \u4f5c\u8005\uff1a\u4e50\u5b57\u8282\u6559\u80b2 https:\/\/www.bilibili.com\/read\/cv7115458\/ \u51fa\u5904\uff1abilibili<\/pre>\n\n\n\n<p><strong>\u6d41\u4e2d\u95f4\u64cd\u4f5c <\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6d41\u7684\u4e2d\u95f4\u64cd\u4f5c\u5206\u4e3a\u4e09\u5927\u7c7b:\u7b5b\u9009\u5207\u7247\u3001\u6620\u5c04\u3001\u6392\u5e8f\u3002<\/p>\n\n\n\n<p>\u7b5b\u9009\u5207\u7247:\u7c7b\u4f3csql \u4e2dwhere \u6761\u4ef6\u5224\u65ad\u7684\u610f\u601d\uff0c\u5bf9\u5143\u7d20\u8fdb\u884c\u7b5b\u9009\u64cd\u4f5c<\/p>\n\n\n\n<p>\u6620\u5c04:\u5bf9\u5143\u7d20\u7ed3\u679c\u8fdb\u884c\u8f6c\u6362 \uff0c\u4f18\u70b9\u7c7b\u4f3cselect \u5b57\u6bb5\u610f\u601d\u6216\u8005\u5bf9\u5143\u7d20\u5185\u5bb9\u8fdb\u884c\u8f6c\u6362\u5904\u7406<\/p>\n\n\n\n<p>\u6392\u5e8f:\u6bd4\u8f83\u597d\u7406\u89e3 \uff0c\u5e38\u7528sql \u4e2d\u6309\u5b57\u6bb5\u5347\u5e8f \u964d\u5e8f\u64cd\u4f5c <\/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\/09\/\u56fe\u7247-44-1024x373.png\" alt=\"\" class=\"wp-image-12811\" width=\"534\" height=\"194\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44-1024x373.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44-300x109.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44-768x279.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44-830x302.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44-230x84.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44-350x127.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44-480x175.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-44.png 1270w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><\/figure><\/div>\n\n\n\n<p>\u6d41\u4e2d\u95f4\u64cd\u4f5c\u6570\u636e\u51c6\u5907\uff08\u8fd9\u91cc\u4ee5\u8ba2\u5355\u6570\u636e\u5904\u7406\u4e3a\u4f8b\uff09<\/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 Order {\n    \/\/ \u8ba2\u5355id\n    private Integer id;\n    \/\/ \u8ba2\u5355\u7528\u6237id\n    private Integer userId;\n    \/\/ \u8ba2\u5355\u7f16\u53f7\n    private String orderNo;\n    \/\/ \u8ba2\u5355\u65e5\u671f\n    private Date orderDate;\n    \/\/ \u6536\u8d27\u5730\u5740\n    private String address;\n    \/\/ \u521b\u5efa\u65f6\u95f4\n    private Date createDate;\n    \/\/ \u66f4\u65b0\u65f6\u95f4\n    private Date updateDate;\n    \/\/ \u8ba2\u5355\u72b6\u6001  0-\u672a\u652f\u4ed8  1-\u5df2\u652f\u4ed8  2-\u5f85\u53d1\u8d27  3-\u5df2\u53d1\u8d27  4-\u5df2\u63a5\u6536  5-\u5df2\u5b8c\u6210\n    private Integer status;\n    \/\/ \u662f\u5426\u6709\u6548  1-\u6709\u6548\u8ba2\u5355  0-\u65e0\u6548\u8ba2\u5355\n    private Integer isValid;\n    \/\/\u8ba2\u5355\u603b\u91d1\u989d\n    private  Double total;\n  }\n\nOrder order01 = new Order(1, 10, \"20190301\",\n                new Date(), \"\u4e0a\u6d77\u5e02-\u6d66\u4e1c\u533a\", new Date(), new Date(), 4, 1, 100.0);\nOrder order02 = new Order(2, 30, \"20190302\",\n                    new Date(), \"\u5317\u4eac\u5e02\u56db\u60e0\u533a\", new Date(), new Date(), 1, 1, 2000.0);\nOrder order03 = new Order(3, 20, \"20190303\",\n                    new Date(), \"\u5317\u4eac\u5e02-\u671d\u9633\u533a\", new Date(), new Date(), 4, 1, 500.0);\nOrder order04 = new Order(4, 40, \"20190304\",\n                    new Date(), \"\u5317\u4eac\u5e02-\u5927\u5174\u533a\", new Date(), new Date(), 4, 1, 256.0);\nOrder order05 = new Order(5, 40, \"20190304\",\n                    new Date(), \"\u4e0a\u6d77\u5e02-\u677e\u6c5f\u533a\", new Date(), new Date(), 4, 1, 1000.0);\nordersList = Arrays.asList(order01, order02, order03, order04, order05); <\/pre>\n\n\n\n<p><strong>\u7b5b\u9009&amp;\u5207\u7247 <\/strong><\/p>\n\n\n\n<ul><li>\u7b5b\u9009\u6709\u6548\u8ba2\u5355<\/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=\"\">\/\/ \u8fc7\u6ee4\u6709\u6548\u8ba2\u5355\nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .forEach(System.out::println); <\/pre>\n\n\n\n<ul><li>\u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u53d6\u7b2c\u4e00\u9875\u6570\u636e(\u6bcf\u98752\u6761\u8bb0\u5f55)<\/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=\"\">\/\/ \u8fc7\u6ee4\u6709\u6548\u8ba2\u5355 \u53d6\u7b2c\u4e00\u9875\u6570\u636e(\u6bcf\u98752\u6761\u8bb0\u5f55) \n ordersList.stream().filter((order) -> order.getIsValid() == 1)\n     .limit(2)\n     .forEach(System.out::println); <\/pre>\n\n\n\n<ul><li>\u7b5b\u9009\u8ba2\u5355\u96c6\u5408\u6709\u6548\u8ba2\u5355 \u53d6\u6700\u540e\u4e00\u6761\u8bb0\u5f55<\/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=\"\">\/\/ \u8fc7\u6ee4\u8ba2\u5355\u96c6\u5408\u6709\u6548\u8ba2\u5355 \u53d6\u6700\u540e\u4e00\u6761\u8bb0\u5f55\nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .skip(ordersList.size() - 2)  \/\/ \u8df3\u8fc7\u524dordersList.size()-2 \u8bb0\u5f55\n    .forEach(System.out::println); \u4f5c\u8005\uff1a\u4e50\u5b57\u8282\u6559\u80b2 https:\/\/www.bilibili.com\/read\/cv7115458\/ \u51fa\u5904\uff1abilibili<\/pre>\n\n\n\n<ul><li>\u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u53d6\u7b2c3\u9875\u6570\u636e(\u6bcf\u98752\u6761\u8bb0\u5f55)<\/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=\"\">\/\/ \u8fc7\u6ee4\u6709\u6548\u8ba2\u5355 \u53d6\u7b2c3\u9875\u6570\u636e(\u6bcf\u98752\u6761\u8bb0\u5f55) \u5e76\u6253\u5370\u5230\u63a7\u5236\u53f0\nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .skip((3 - 1) * 2)\n    .limit(2)\n    .forEach(System.out::println); \u4f5c\u8005\uff1a\u4e50\u5b57\u8282\u6559\u80b2 https:\/\/www.bilibili.com\/read\/cv7115458\/ \u51fa\u5904\uff1abilibili<\/pre>\n\n\n\n<ul><li>\u7b5b\u9009\u65e0\u6548\u8ba2\u5355\u53bb\u9664\u91cd\u590d\u8ba2\u5355\u53f7\u8bb0\u5f55 <\/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=\"\">\/\/ \u8fc7\u6ee4\u65e0\u6548\u8ba2\u5355 \u53bb\u9664\u91cd\u590d\u8ba2\u5355\u53f7\u8bb0\u5f55  \u91cd\u5199Order equals \u4e0e hashCode \u65b9\u6cd5\nordersList.stream().filter((order) -> order.getIsValid() == 0)\n    .distinct()\n    .forEach(System.out::println); \u4f5c\u8005\uff1a\u4e50\u5b57\u8282\u6559\u80b2 https:\/\/www.bilibili.com\/read\/cv7115458\/ \u51fa\u5904\uff1abilibili<\/pre>\n\n\n\n<p><strong>\u6620\u5c04<\/strong> <\/p>\n\n\n\n<ul><li>\u8fc7\u6ee4\u6709\u6548\u8ba2\u5355,\u83b7\u53d6\u6240\u6709\u8ba2\u5355\u7f16\u53f7<\/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=\"\">\/\/\u8fc7\u6ee4\u6709\u6548\u8ba2\u5355\uff0c\u83b7\u53d6\u6240\u6709\u8ba2\u5355\u7f16\u53f7\nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .map((order) -> order.getOrderNo())\n    .forEach(System.out::println);\n\n    \u8fc7\u6ee4\u6709\u6548\u8ba2\u5355 ,\u5e76\u5206\u79bb\u6bcf\u4e2a\u8ba2\u5355\u4e0b\u6536\u8d27\u5730\u5740\u5e02\u533a\u4fe1\u606f\n\nordersList.stream().map(o -> o.getAddress()\n    .split(\"-\"))\n    .flatMap(Arrays::stream)\n    .forEach(System.out::println); <\/pre>\n\n\n\n<p><strong>\u6392\u5e8f <\/strong><\/p>\n\n\n\n<ul><li>\u8fc7\u6ee4\u6709\u6548\u8ba2\u5355 \u6839\u636e\u7528\u6237id \u8fdb\u884c\u6392\u5e8f <\/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=\"\">\/\/\u8fc7\u6ee4\u6709\u6548\u8ba2\u5355 \u6839\u636e\u7528\u6237id \u8fdb\u884c\u6392\u5e8f\nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .sorted((o1, o2) -> o1.getUserId() - o2.getUserId())\n    .forEach(System.out::println);  \n\n \/\/\u6216\u8005\u7b49\u4ef7\u5199\u6cd5 \nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .sorted(Comparator.comparingInt(Order::getUserId))\n    .forEach(System.out::println); <\/pre>\n\n\n\n<ul><li>\u8fc7\u6ee4\u6709\u6548\u8ba2\u5355 ,\u6839\u636e\u8ba2\u5355\u72b6\u6001\u6392\u5e8f \u5982\u679c\u8ba2\u5355\u72b6\u6001\u76f8\u540c\u6839\u636e\u8ba2\u5355\u521b\u5efa\u65f6\u95f4\u6392\u5e8f <\/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=\"\">\/\/\u8fc7\u6ee4\u6709\u6548\u8ba2\u5355  \u5982\u679c\u8ba2\u5355\u72b6\u6001\u76f8\u540c \u6839\u636e\u8ba2\u5355\u521b\u5efa\u65f6\u95f4\u6392\u5e8f \u53cd\u4e4b\u6839\u636e\u8ba2\u5355\u72b6\u6001\u6392\u5e8f\nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .sorted((o1, o2) -> {\n        if (o1.getStatus().equals(o2.getStatus())) {\n            return o1.getCreateDate().compareTo(o2.getCreateDate());\n        } else {\n            return o1.getStatus().compareTo(o2.getStatus());\n    }})\n    .forEach(System.out::println);\n\n\n\/\/ \u7b49\u4ef7\u5f62\u5f0f\nordersList.stream().filter((order) -> order.getIsValid() == 1)\n    .sorted(Comparator.comparing(Order::getCreateDate)\n    .thenComparing(Comparator.comparing(Order::getStatus)))\n    .forEach(System.out::println); <\/pre>\n\n\n\n<p><strong>\u6d41\u7684\u7ec8\u6b62\u64cd\u4f5c <\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u7ec8\u6b62\u64cd\u4f5c\u4f1a\u4ece\u6d41\u7684\u6d41\u6c34\u7ebf\u751f\u6210\u7ed3\u679c\u3002\u5176\u7ed3\u679c\u662f\u4efb\u4f55\u4e0d\u662f\u6d41\u7684\u503c\uff0c\u6bd4\u5982\u5e38\u89c1\u7684List\u3001 Integer\uff0c\u751a \u81f3void\u7b49\u7ed3\u679c\u3002\u5bf9\u4e8e\u6d41\u7684\u7ec8\u6b62\u64cd\u4f5c\uff0c\u5206\u4e3a\u4ee5\u4e0b\u4e09\u7c7b:<\/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\/09\/\u56fe\u7247-45-1024x649.png\" alt=\"\" class=\"wp-image-12812\" width=\"442\" height=\"280\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45-1024x649.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45-300x190.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45-768x486.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45-830x526.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45-230x146.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45-350x222.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45-480x304.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-45.png 1320w\" sizes=\"(max-width: 442px) 100vw, 442px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u67e5\u627e\u4e0e\u5339\u914d<\/strong> <\/p>\n\n\n\n<ul><li>\u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u5339\u914d\u662f\u5426\u5168\u90e8\u4e3a\u5df2\u652f\u4ed8\u8ba2\u5355 <\/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=\"\"> \/\/ \u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u5339\u914d\u662f\u5426\u5168\u90e8\u4e3a\u5df2\u652f\u4ed8\u8ba2\u5355\nSystem.out.println(\"allMatch\u5339\u914d\u7ed3\u679c:\" + \n                     ordersList.stream()\n                     .filter((order) -> order.getIsValid() == 1)\n                  .allMatch((o) -> o.getStatus() != 0)\n                  ); <\/pre>\n\n\n\n<ul><li>\u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u5339\u914d\u662f\u5426\u5b58\u5728\u672a\u652f\u4ed8\u8ba2\u5355 <\/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=\"\">\/\/ \u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u5339\u914d\u662f\u5426\u5b58\u5728\u672a\u652f\u4ed8\u8ba2\u5355\nSystem.out.println(\"anyMatch\u5339\u914d\u7ed3\u679c:\" + \n                     ordersList.stream()\n                        .filter((order) -> order.getIsValid() == 1)\n                        .anyMatch((o) -> o.getStatus() == 0)\n                  ); <\/pre>\n\n\n\n<ul><li>\u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u5168\u90e8\u672a\u5b8c\u6210\u8ba2\u5355 <\/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=\"\">\/\/ \u7b5b\u9009\u6709\u6548\u8ba2\u5355 \u5168\u90e8\u672a\u5b8c\u6210\u8ba2\u5355\nSystem.out.println(\"noneMatch\u5339\u914d\u7ed3\u679c:\" + \n                    ordersList.stream()\n                     .filter((order) -> order.getIsValid() == 1)\n                     .noneMatch((o) -> o.getStatus() == 5)\n                  ); <\/pre>\n\n\n\n<p><strong>\u5f52\u7ea6&amp;\u6536\u96c6 <\/strong><\/p>\n\n\n\n<ul><li>\u5f52\u7ea6 <\/li><\/ul>\n\n\n\n<p>\u5c06\u6d41\u4e2d\u5143\u7d20\u53cd\u590d\u7ed3\u5408\u8d77\u6765\uff0c\u5f97\u5230\u4e00\u4e2a\u503c\u7684\u64cd\u4f5c <\/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=\"\">\/\/ \u8ba1\u7b97\u6709\u6548\u8ba2\u5355\u603b\u91d1\u989d\n        System.out.println(\"\u6709\u6548\u8ba2\u5355\u603b\u91d1\u989d:\" + \n                            ordersList.stream()\n                                .filter((order) -> order.getIsValid() == 1)\n                                .map(Order::getTotal)\n                                .reduce(Double::sum)\n                                .get()\n                          ); <\/pre>\n\n\n\n<p><strong>\u6d41\u7684\u5e94\u7528 <\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>ava8\u5f15\u5165Stream\u6d41\u64cd\u4f5c\uff0c\u4f7f\u5f97\u5bf9\u5143\u7d20\u7684\u5904\u7406\u66f4\u52a0\u7684\u65b9\u4fbf\u5feb\u6377\uff0c\u901a\u8fc7Stream\u63d0\u4f9b\u7684\u76f8\u5173\u65b9\u6cd5\u5f88\u597d\u7684\u7ed3\u5408Lambda\u3001\u51fd\u6570\u5f0f\u63a5\u53e3\u3001\u65b9\u6cd5\u5f15\u7528\u7b49\u76f8\u5173\u5185\u5bb9\uff0c\u4f7f\u5f97\u6d41\u7684\u5904\u7406\u76f8\u6bd4\u8f83\u539f\u59cb\u96c6\u5408\u5904\u7406\u4ee3\u7801\u6781\u5927\u7b80\u5316\uff0cStream\u652f\u6301\u51fd\u6570\u7684\u94fe\u5f0f\u8c03\u7528\uff0c\u4ee3\u7801\u4e0a\u66f4\u52a0\u7d27\u51d1\u540c\u65f6Stream\u652f\u6301\u7684\u5143\u7d20\u7684\u5e76\u884c\u5316\u5904\u7406\u63d0\u9ad8\u4e86\u7a0b\u5e8f\u7684\u6267\u884c\u6027\u80fd\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8eStream\u6d41\u7684\u5e94\u7528\u901a\u5e38\u5728\u96c6\u5408\u5143\u7d20\u6570\u636e\u5904\u7406\u4e0a\u7279\u522b\u662f\u5bf9\u5143\u7d20\u9700\u8981\u8fdb\u884c\u591a\u6b21\u5904\u7406\u7684\u60c5\u51b5\uff0c\u540c\u65f6\u5bf9\u4e8e\u51fd\u6570\u5f0f\u7f16\u7a0b\u7684\u5473\u9053\u66f4\u52a0\u6d53\u91cd\uff0c\u4e5f\u662f\u4ee5\u540e\u5f00\u53d1\u7684\u4e00\u4e2a\u8d8b\u52bf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf4\u8d77\u6d41\uff0c\u6211\u4eec\u4f1a\u60f3\u8d77\u624b\u673a \uff0c\u7535\u8111\u7ec4\u88c5\u6d41\u6c34\u7ebf\uff0c\u7269\u6d41\u4ed3\u5e93\u5546\u54c1\u5305\u88c5\u6d41\u6c34\u7ebf\u7b49\u7b49\u3002\u5982\u679c\u628a\u624b\u673a ,\u7535\u8111,\u5305\u88f9\u770b\u505a\u6700\u7ec8\u7ed3\u679c\u7684\u8bdd [&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\/12804"}],"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=12804"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12804\/revisions"}],"predecessor-version":[{"id":12813,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12804\/revisions\/12813"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}