{"id":37863,"date":"2024-11-26T10:26:43","date_gmt":"2024-11-26T02:26:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/37863\/"},"modified":"2024-11-26T10:26:43","modified_gmt":"2024-11-26T02:26:43","slug":"java%e6%80%8e%e4%b9%88%e5%88%9b%e5%bb%ba%e4%bb%bb%e6%84%8f%e9%95%bf%e5%ba%a6%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/37863\/","title":{"rendered":"java\u600e\u4e48\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u56db\u79cd\u65b9\u6cd5\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u7684 java \u6570\u7ec4\uff1a1. \u6570\u7ec4\u5b57\u9762\u91cf\uff1b2. new \u5173\u952e\u5b57\uff1b3. arrays.fill() \u65b9\u6cd5\uff1b4. var \u5173\u952e\u5b57\uff08\u4ec5\u9650 java 10 \u53ca\u66f4\u9ad8\u7248\u672c\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111312062242784.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u600e\u4e48\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u7528 Java \u521b\u5efa\u4efb\u610f\u957f\u5ea6\u6570\u7ec4<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u7684\u6570\u7ec4\uff1a<\/p>\n<ol>\n<li><strong>\u6570\u7ec4\u5b57\u9762\u91cf<\/strong><\/li>\n<\/ol>\n<p>\u4f7f\u7528\u82b1\u62ec\u53f7\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u5e76\u6307\u5b9a\u6bcf\u4e2a\u5143\u7d20\u7684\u503c\uff1a<\/p>\n<pre>int[] numbers = {1, 2, 3, 4, 5};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li><strong>new \u5173\u952e\u5b57<\/strong><\/li>\n<\/ol>\n<p>\u4f7f\u7528 new \u5173\u952e\u5b57\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\uff0c\u5e76\u6307\u5b9a\u6570\u7ec4\u7c7b\u578b\u53ca\u5176\u957f\u5ea6\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>int[] numbers = new int[5];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li><strong>Arrays.fill() \u65b9\u6cd5<\/strong><\/li>\n<\/ol>\n<p>\u4f7f\u7528 Arrays.fill() \u65b9\u6cd5\u4e3a\u6570\u7ec4\u586b\u5145\u6307\u5b9a\u503c\uff1a<\/p>\n<pre>int[] numbers = new int[5];\nArrays.fill(numbers, 3);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li><strong>Java 10 \u4e2d\u7684 var \u5173\u952e\u5b57 (\u4ec5\u9650 Java 10 \u53ca\u66f4\u9ad8\u7248\u672c)<\/strong><\/li>\n<\/ol>\n<p>\u4f7f\u7528 var \u5173\u952e\u5b57\u63a8\u65ad\u6570\u7ec4\u7c7b\u578b\u5e76\u521d\u59cb\u5316\u6570\u7ec4\uff1a<\/p>\n<pre>\/\/ Java 10 \u53ca\u66f4\u9ad8\u7248\u672c\nvar numbers = {1, 2, 3, 4, 5};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4f7f\u7528\u6570\u7ec4\u5b57\u9762\u91cf\u521b\u5efa\u7684\u6570\u7ec4\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u7684\u957f\u5ea6\u4e0d\u80fd\u88ab\u6539\u53d8\u3002\u800c\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u521b\u5efa\u7684\u6570\u7ec4\u662f\u53ef\u53d8\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528 array.length \u6765\u8bbf\u95ee\u5176\u957f\u5ea6\u5e76\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u6570\u7ec4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u56db\u79cd\u65b9\u6cd5\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u7684 java \u6570\u7ec4\uff1a1. \u6570\u7ec4\u5b57\u9762\u91cf\uff1b2. new \u5173\u952e\u5b57\uff1b3. arrays.fill() \u65b9\u6cd5\uff1b4. var \u5173\u952e\u5b57\uff08\u4ec5\u9650 java 10 \u53ca\u66f4\u9ad8\u7248\u672c\uff09\u3002 \u5982\u4f55\u7528 Java \u521b\u5efa\u4efb\u610f\u957f\u5ea6\u6570\u7ec4 \u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u521b\u5efa\u4efb\u610f\u957f\u5ea6\u7684\u6570\u7ec4\uff1a \u6570\u7ec4\u5b57\u9762\u91cf \u4f7f\u7528\u82b1\u62ec\u53f7\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u5e76\u6307\u5b9a\u6bcf\u4e2a\u5143\u7d20\u7684\u503c\uff1a int[] numbers = {1, 2, 3, 4, 5}; \u767b\u5f55\u540e\u590d\u5236 new \u5173\u952e\u5b57 \u4f7f\u7528 new \u5173\u952e\u5b57\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\uff0c\u5e76\u6307\u5b9a\u6570\u7ec4\u7c7b\u578b\u53ca\u5176\u957f\u5ea6\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b int[] numbers = new int[5]; \u767b\u5f55\u540e\u590d\u5236 Arrays.fill() \u65b9\u6cd5 \u4f7f\u7528 Arrays.fill() \u65b9\u6cd5\u4e3a\u6570\u7ec4\u586b\u5145\u6307\u5b9a\u503c\uff1a int[] numbers = new int[5]; Arrays.fill(numbers, 3); \u767b\u5f55\u540e\u590d\u5236 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-37863","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=37863"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37863\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=37863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=37863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=37863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}