{"id":203962,"date":"2025-05-22T14:55:59","date_gmt":"2025-05-22T06:55:59","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203962\/"},"modified":"2025-05-22T14:55:59","modified_gmt":"2025-05-22T06:55:59","slug":"java%e6%96%b9%e6%b3%95%e5%bc%95%e7%94%a8%e7%b1%bb%e5%ae%9e%e4%be%8b%e6%96%b9%e6%b3%95%e7%9a%84%e5%8e%9f%e7%90%86%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203962\/","title":{"rendered":"Java\u65b9\u6cd5\u5f15\u7528\u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5\u201d\u7684\u539f\u7406\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Java\u65b9\u6cd5\u5f15\u7528\u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5\u201d\u7684\u539f\u7406\u662f\u4ec0\u4e48\uff1f <\/h1>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aJava\u65b9\u6cd5\u5f15\u7528\u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5\u201d\u7684\u539f\u7406\u662f\u4ec0\u4e48\uff1f \u300b<\/span>\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241201\/1733064696674c77f88eed9.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u4e3a\u4ec0\u4e48 java \u53ef\u4ee5\u901a\u8fc7 \u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5\u201d \u83b7\u53d6\u5230\u65b9\u6cd5\u7684\u5f15\u7528\uff1f<\/strong><\/p>\n<p>java \u7684\u65b9\u6cd5\u5f15\u7528\u63d0\u4f9b\u4e86\u83b7\u53d6\u65b9\u6cd5\u5f15\u7528\u7684\u4e00\u79cd\u7b80\u6d01\u65b9\u5f0f\uff0c\u8bed\u6cd5\u4e3a \u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5\u201d\u3002\u5bf9\u4e8e\u8fd9\u79cd\u5f15\u7528\u65b9\u5f0f\uff0c\u5176\u539f\u7406\u548c\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li><strong>\u5f15\u7528\u65b9\u6cd5\u53c2\u6570\u4e0e\u62bd\u8c61\u65b9\u6cd5\u53c2\u6570\u5bf9\u5e94\uff1a<\/strong>\u65b9\u6cd5\u5f15\u7528\u7684\u53c2\u6570\u5fc5\u987b\u4e0e\u62bd\u8c61\u65b9\u6cd5\u7684\u7b2c 2 \u4e2a\u81f3\u5012\u6570\u7b2c 1 \u4e2a\u53c2\u6570\u4fdd\u6301\u4e00\u81f4\u3002\u7531\u4e8e\u5b9e\u4f8b\u65b9\u6cd5\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u9690\u542b\u4e3a this\uff0c\u56e0\u6b64\u53ea\u6709\u5728 this \u7684\u7c7b\u578b\u4e0e\u62bd\u8c61\u65b9\u6cd5\u7b2c\u4e00\u4e2a\u53c2\u6570\u7c7b\u578b\u4e00\u81f4\u65f6\uff0c\u624d\u53ef\u4ee5\u4f7f\u7528\u7c7b\u540d\u5f15\u7528\u5b9e\u4f8b\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>ArrayList&lt;String&gt; list = new ArrayList&lt;&gt;();\nCollections.addAll(list, \"a\", \"b\", \"c\");\n\/\/ \u5c06\u96c6\u5408\u4e2d\u7684\u5b57\u6bcd\u8f6c\u4e3a\u5927\u5199\nlist.stream()\n        \/\/ \u6570\u636e\u6d41\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u4e3a String\uff0c\u6240\u4ee5\u53ef\u4ee5\u5f15\u7528 String \u7c7b\u4e2d\u7684\u5b9e\u4f8b\u65b9\u6cd5\n        .map(String::toUpperCase)\n        .forEach(System.out::println);<\/pre>\n<p>\u5728\u8be5\u793a\u4f8b\u4e2d\uff0cmap \u64cd\u4f5c\u4f7f\u7528 string::touppercase \u6765\u5f15\u7528 string.touppercase() \u65b9\u6cd5\u3002\u8fd9\u662f\u56e0\u4e3a stream \u4e2d\u7684\u6570\u636e\u7c7b\u578b\u4e3a string\uff0c\u548c string.touppercase() \u65b9\u6cd5\u7684\u53c2\u6570\u4e00\u81f4\u3002\u6b64\u5916\uff0c\u76ee\u6807\u5f15\u7528\uff08this\uff09\u662f stream \u4e2d\u7684\u5143\u7d20\uff0c\u5176\u7c7b\u578b\u4e0e collections.addall \u4e2d\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u7c7b\u578b\uff08string\uff09\u4e00\u81f4\u3002\u56e0\u6b64\uff0c\u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5\u201d\u7684\u5f15\u7528\u65b9\u5f0f\u7b26\u5408\u8981\u6c42\u3002<\/p>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300aJava\u65b9\u6cd5\u5f15\u7528\u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5\u201d\u7684\u539f\u7406\u662f\u4ec0\u4e48\uff1f \u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u65b9\u6cd5\u5f15\u7528\u201c\u7c7b::\u5b9e\u4f8b\u65b9\u6cd5&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-203962","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=203962"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203962\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}