{"id":65232,"date":"2025-05-03T17:07:34","date_gmt":"2025-05-03T09:07:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65232\/"},"modified":"2025-05-03T17:07:34","modified_gmt":"2025-05-03T09:07:34","slug":"java%e5%bc%95%e7%94%a8%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65232\/","title":{"rendered":"java\u5f15\u7528\u6570\u7ec4\u600e\u4e48"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u5f15\u7528\u6570\u7ec4\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\uff1a\u58f0\u660e\u4e00\u4e2a\u6307\u5411\u6570\u7ec4\u8d77\u59cb\u4f4d\u7f6e\u7684\u5f15\u7528\u53d8\u91cf\u3002\u6570\u7ec4\u5bf9\u8c61\uff1a\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u6570\u7ec4\u4fe1\u606f\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982\u957f\u5ea6\u548c\u5143\u7d20\u7c7b\u578b\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/12\/2024111213271896137.jpg\" class=\"aligncenter\" title=\"java\u5f15\u7528\u6570\u7ec4\u600e\u4e48\u63d2\u56fe\" alt=\"java\u5f15\u7528\u6570\u7ec4\u600e\u4e48\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4e2d\u5f15\u7528\u6570\u7ec4\u7684\u65b9\u6cd5<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u53ef\u4ee5\u5f15\u7528\u6570\u7ec4\uff1a<\/p>\n<ul>\n<li><strong>\u6570\u7ec4\u5f15\u7528\u53d8\u91cf<\/strong><\/li>\n<li><strong>\u6570\u7ec4\u5bf9\u8c61<\/strong><\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u5f15\u7528\u53d8\u91cf<\/strong><\/p>\n<p>\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\u662f\u4e00\u79cd\u6307\u5411\u6570\u7ec4\u8d77\u59cb\u4f4d\u7f6e\u7684\u5f15\u7528\u3002\u5b83\u662f\u4e00\u4e2a\u6307\u5411\u6570\u7ec4\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u6307\u9488\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u8981\u58f0\u660e\u4e00\u4e2a\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>int[] arrRef;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5f15\u7528\u53d8\u91cf arrRef\uff0c\u5b83\u6307\u5411\u4e00\u4e2a int \u7c7b\u578b\u6570\u7ec4\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002<\/p>\n<p><strong>\u6570\u7ec4\u5bf9\u8c61<\/strong><\/p>\n<p>\u6570\u7ec4\u5bf9\u8c61\u662f\u4e00\u4e2a\u8868\u793a\u6570\u7ec4\u672c\u8eab\u7684\u5bf9\u8c61\u3002\u5b83\u5305\u542b\u6709\u5173\u6570\u7ec4\u7684\u4fe1\u606f\uff0c\u4f8b\u5982\u5176\u957f\u5ea6\u548c\u5143\u7d20\u7c7b\u578b\u3002<\/p>\n<p>\u8981\u521b\u5efa\u6570\u7ec4\u5bf9\u8c61\uff0c\u8bf7\u4f7f\u7528 new \u5173\u952e\u5b57\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>int[] arrObj = new int[10];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u957f\u5ea6\u4e3a 10 \u7684 int \u6570\u7ec4\u5bf9\u8c61\uff0c\u5e76\u5c06\u5f15\u7528\u5b58\u50a8\u5728 arrObj \u53d8\u91cf\u4e2d\u3002<\/p>\n<p><strong>\u4f7f\u7528\u5f15\u7528\u5f15\u7528\u6570\u7ec4<\/strong><\/p>\n<p>\u4e00\u65e6\u58f0\u660e\u4e86\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\u6216\u6570\u7ec4\u5bf9\u8c61\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u8bbf\u95ee\u548c\u64cd\u4f5c\u6570\u7ec4\u3002<\/p>\n<ul>\n<li> <strong>\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\uff1a<\/strong>\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/li>\n<\/ul>\n<pre>arrRef[0] = 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u8bbe\u7f6e\u4e3a 10\u3002<\/p>\n<ul>\n<li> <strong>\u6570\u7ec4\u5bf9\u8c61\uff1a<\/strong>\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/li>\n<\/ul>\n<pre>arrObj[0] = 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u5916\uff0c\u6570\u7ec4\u5bf9\u8c61\u8fd8\u63d0\u4f9b\u5176\u4ed6\u65b9\u6cd5\uff0c\u4f8b\u5982 length\uff0c\u5b83\u8fd4\u56de\u6570\u7ec4\u7684\u957f\u5ea6\u3002<\/p>\n<p><strong>\u9009\u62e9\u5f15\u7528\u65b9\u6cd5<\/strong><\/p>\n<p>\u662f\u4f7f\u7528\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\u8fd8\u662f\u6570\u7ec4\u5bf9\u8c61\u53d6\u51b3\u4e8e\u5177\u4f53\u60c5\u51b5\u3002\u901a\u5e38\uff0c\u5982\u679c\u53ea\u8bbf\u95ee\u6570\u7ec4\u7684\u5143\u7d20\uff0c\u5219\u4f7f\u7528\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\u5c31\u8db3\u591f\u4e86\u3002\u4f46\u662f\uff0c\u5982\u679c\u9700\u8981\u8bbf\u95ee\u6709\u5173\u6570\u7ec4\u7684\u5143\u6570\u636e\uff08\u4f8b\u5982\u5176\u957f\u5ea6\uff09\uff0c\u5219\u5fc5\u987b\u4f7f\u7528\u6570\u7ec4\u5bf9\u8c61\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u5f15\u7528\u6570\u7ec4\u600e\u4e48\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 java \u4e2d\uff0c\u5f15\u7528\u6570\u7ec4\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\uff1a\u58f0\u660e\u4e00\u4e2a\u6307\u5411\u6570\u7ec4\u8d77\u59cb\u4f4d\u7f6e\u7684\u5f15\u7528\u53d8\u91cf\u3002\u6570\u7ec4\u5bf9\u8c61\uff1a\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u6570\u7ec4\u4fe1\u606f\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982\u957f\u5ea6\u548c\u5143\u7d20\u7c7b\u578b\u3002 Java \u4e2d\u5f15\u7528\u6570\u7ec4\u7684\u65b9\u6cd5 \u5728 Java \u4e2d\uff0c\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u53ef\u4ee5\u5f15\u7528\u6570\u7ec4\uff1a \u6570\u7ec4\u5f15\u7528\u53d8\u91cf \u6570\u7ec4\u5bf9\u8c61 \u6570\u7ec4\u5f15\u7528\u53d8\u91cf \u6570\u7ec4\u5f15\u7528\u53d8\u91cf\u662f\u4e00\u79cd\u6307\u5411\u6570\u7ec4\u8d77\u59cb\u4f4d\u7f6e\u7684\u5f15\u7528\u3002\u5b83\u662f\u4e00\u4e2a\u6307\u5411\u6570\u7ec4\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u6307\u9488\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u8981\u58f0\u660e\u4e00\u4e2a\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a int[] arrRef; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5f15\u7528\u53d8\u91cf arrRef\uff0c\u5b83\u6307\u5411\u4e00\u4e2a int \u7c7b\u578b\u6570\u7ec4\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002 \u6570\u7ec4\u5bf9\u8c61 \u6570\u7ec4\u5bf9\u8c61\u662f\u4e00\u4e2a\u8868\u793a\u6570\u7ec4\u672c\u8eab\u7684\u5bf9\u8c61\u3002\u5b83\u5305\u542b\u6709\u5173\u6570\u7ec4\u7684\u4fe1\u606f\uff0c\u4f8b\u5982\u5176\u957f\u5ea6\u548c\u5143\u7d20\u7c7b\u578b\u3002 \u8981\u521b\u5efa\u6570\u7ec4\u5bf9\u8c61\uff0c\u8bf7\u4f7f\u7528 new \u5173\u952e\u5b57\uff0c\u5982\u4e0b\u6240\u793a\uff1a int[] arrObj = new int[10]; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u957f\u5ea6\u4e3a 10 \u7684 int \u6570\u7ec4\u5bf9\u8c61\uff0c\u5e76\u5c06\u5f15\u7528\u5b58\u50a8\u5728 arrObj \u53d8\u91cf\u4e2d\u3002 \u4f7f\u7528\u5f15\u7528\u5f15\u7528\u6570\u7ec4 \u4e00\u65e6\u58f0\u660e\u4e86\u6570\u7ec4\u5f15\u7528\u53d8\u91cf\u6216\u6570\u7ec4\u5bf9\u8c61\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u8bbf\u95ee\u548c\u64cd\u4f5c\u6570\u7ec4\u3002 \u6570\u7ec4\u5f15\u7528\u53d8\u91cf\uff1a\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff0c\u5982\u4e0b\u6240\u793a\uff1a arrRef[0] = 10; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u8bbe\u7f6e\u4e3a 10\u3002 \u6570\u7ec4\u5bf9\u8c61\uff1a\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff0c\u5982\u4e0b\u6240\u793a\uff1a arrObj[0] = 10; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u5916\uff0c\u6570\u7ec4\u5bf9\u8c61\u8fd8\u63d0\u4f9b\u5176\u4ed6\u65b9\u6cd5\uff0c\u4f8b\u5982 length\uff0c\u5b83\u8fd4\u56de\u6570\u7ec4\u7684\u957f\u5ea6\u3002 [&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-65232","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65232","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=65232"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65232\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}