{"id":66582,"date":"2025-05-03T09:57:12","date_gmt":"2025-05-03T01:57:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66582\/"},"modified":"2025-05-03T09:57:12","modified_gmt":"2025-05-03T01:57:12","slug":"java%e5%ae%9a%e4%b9%89%e5%85%a8%e5%b1%80%e5%8f%98%e9%87%8f%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e7%94%a8-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66582\/","title":{"rendered":"java\u5b9a\u4e49\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u600e\u4e48\u7528"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u7c7b\u540d\u76f4\u63a5\u8bbf\u95ee\uff0c\u5176\u5b9a\u4e49\u6b65\u9aa4\u5982\u4e0b\uff1a\u4f7f\u7528 static \u5173\u952e\u5b57\u4fee\u9970\u5e76\u5b9a\u4e49\u6570\u7ec4\u3002\u4f7f\u7528\u7c7b\u540d\u548c\u7d22\u5f15\u8bbf\u95ee\u5e76\u8bbe\u7f6e\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111606544941843.jpg\" class=\"aligncenter\" title=\"java\u5b9a\u4e49\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u600e\u4e48\u7528\u63d2\u56fe\" alt=\"java\u5b9a\u4e49\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u600e\u4e48\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u5b9a\u4e49\u548c\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u6570\u7ec4<\/strong><\/p>\n<p>\u8981\u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff0c\u9700\u8981\u5728\u7c7b\u7684\u5916\u90e8\u8fdb\u884c\u5b9a\u4e49\uff0c\u4e14\u4f7f\u7528 <strong>static<\/strong> \u5173\u952e\u5b57\u4fee\u9970\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>public class MyClass {\n    \/\/ \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\n    private static int[] myArray = new int[10];\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u6570\u7ec4<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u7c7b\u540d\u76f4\u63a5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff0c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>MyClass.myArray[index] = value;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li> <strong>MyClass<\/strong> \u662f\u5b9a\u4e49\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u7684\u7c7b\u540d<\/li>\n<li> <strong>index<\/strong> \u662f\u6570\u7ec4\u7d22\u5f15<\/li>\n<li> <strong>value<\/strong> \u662f\u8981\u8d4b\u503c\u7684\u503c<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff1a<\/p>\n<pre>public class Main {\n    public static void main(String[] args) {\n        \/\/ \u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u5e76\u8bbe\u7f6e\u503c\n        MyClass.myArray[0] = 10;\n        MyClass.myArray[1] = 20;\n\n        \/\/ \u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u5e76\u83b7\u53d6\u503c\n        System.out.println(\"myArray[0] = \" + MyClass.myArray[0]);\n        System.out.println(\"myArray[1] = \" + MyClass.myArray[1]);\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre>myArray[0] = 10\nmyArray[1] = 20<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u5b9a\u4e49\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u600e\u4e48\u7528\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>java \u4e2d\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u7c7b\u540d\u76f4\u63a5\u8bbf\u95ee\uff0c\u5176\u5b9a\u4e49\u6b65\u9aa4\u5982\u4e0b\uff1a\u4f7f\u7528 static \u5173\u952e\u5b57\u4fee\u9970\u5e76\u5b9a\u4e49\u6570\u7ec4\u3002\u4f7f\u7528\u7c7b\u540d\u548c\u7d22\u5f15\u8bbf\u95ee\u5e76\u8bbe\u7f6e\u503c\u3002 Java \u5b9a\u4e49\u548c\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u6570\u7ec4 \u8981\u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff0c\u9700\u8981\u5728\u7c7b\u7684\u5916\u90e8\u8fdb\u884c\u5b9a\u4e49\uff0c\u4e14\u4f7f\u7528 static \u5173\u952e\u5b57\u4fee\u9970\u3002\u4f8b\u5982\uff1a public class MyClass { \/\/ \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u6570\u7ec4 private static int[] myArray = new int[10]; } \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u6570\u7ec4 \u53ef\u4ee5\u4f7f\u7528\u7c7b\u540d\u76f4\u63a5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff0c\u8bed\u6cd5\u5982\u4e0b\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b MyClass.myArray[index] = value; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a MyClass \u662f\u5b9a\u4e49\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u7684\u7c7b\u540d index \u662f\u6570\u7ec4\u7d22\u5f15 value \u662f\u8981\u8d4b\u503c\u7684\u503c \u793a\u4f8b \u4ee5\u4e0b\u793a\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff1a public class Main { public static void main(String[] args) { \/\/ \u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\u5e76\u8bbe\u7f6e\u503c MyClass.myArray[0] = 10; [&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-66582","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66582","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=66582"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66582\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}