{"id":38160,"date":"2024-11-26T10:45:06","date_gmt":"2024-11-26T02:45:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/38160\/"},"modified":"2024-11-26T10:45:06","modified_gmt":"2024-11-26T02:45:06","slug":"java%e6%80%8e%e4%b9%88%e6%8a%8a%e5%af%b9%e8%b1%a1%e6%94%be%e8%bf%9b%e6%95%b0%e7%bb%84%e4%b8%ad","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/38160\/","title":{"rendered":"java\u600e\u4e48\u628a\u5bf9\u8c61\u653e\u8fdb\u6570\u7ec4\u4e2d"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\u53ef\u5c06\u5bf9\u8c61\u5b58\u5165\u6570\u7ec4\uff1a\u521b\u5efa\u6307\u5b9a\u7c7b\u578b\u5bf9\u8c61\u7684\u6570\u7ec4\uff0c\u5982 student[] students = new student[10];\u7528\u7d22\u5f15\u63d2\u5165\u5bf9\u8c61\uff0c\u5982 students[0] = student1;\u7528\u7d22\u5f15\u8bbf\u95ee\u5bf9\u8c61\uff0c\u5982 student student = students[0];\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/14\/2024111409481725447.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u628a\u5bf9\u8c61\u653e\u8fdb\u6570\u7ec4\u4e2d\u63d2\u56fe\" alt=\"java\u600e\u4e48\u628a\u5bf9\u8c61\u653e\u8fdb\u6570\u7ec4\u4e2d\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u5c06\u5bf9\u8c61\u653e\u5165\u6570\u7ec4\u4e2d<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u5c06\u5bf9\u8c61\u653e\u7f6e\u5728\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1a<\/p>\n<p><strong>1. \u521b\u5efa\u4e00\u4e2a\u6570\u7ec4<\/strong><\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u7c7b\u578b\u5bf9\u8c61\u7684\u6570\u7ec4\uff0c\u5176\u4e2d\u7c7b\u578b\u4e0e\u6240\u8981\u5b58\u50a8\u7684\u5bf9\u8c61\u4e00\u81f4\u3002\u4f8b\u5982\uff0c\u8981\u5b58\u50a8 Student \u7c7b\u7684\u5bf9\u8c61\uff0c\u5219\u9700\u8981\u521b\u5efa\u4ee5\u4e0b\u6570\u7ec4\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>Student[] students = new Student[10];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u5411\u6570\u7ec4\u4e2d\u63d2\u5165\u5bf9\u8c61<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u7684\u7d22\u5f15\u6765\u5411\u5176\u4e2d\u63d2\u5165\u5bf9\u8c61\u3002\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u8868\u793a\u6570\u7ec4\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u3002\u4f8b\u5982\uff0c\u8981\u5411\u6570\u7ec4 students \u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u63d2\u5165\u4e00\u4e2a Student \u5bf9\u8c61 student1\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>students[0] = student1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u8bbf\u95ee\u6570\u7ec4\u4e2d\u7684\u5bf9\u8c61<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u7684\u7d22\u5f15\u6765\u8bbf\u95ee\u5176\u5143\u7d20\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u6570\u7ec4 students \u4e2d\u7b2c\u4e00\u4e2a\u5143\u7d20\uff08\u7d22\u5f15\u4e3a 0\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>Student student = students[0];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5c06\u5bf9\u8c61\u653e\u5165\u6570\u7ec4\u4e2d\uff1a<\/p>\n<pre>public class Main {\n    public static void main(String[] args) {\n        \/\/ \u521b\u5efa\u4e00\u4e2a Student \u5bf9\u8c61\u6570\u7ec4\n        Student[] students = new Student[10];\n\n        \/\/ \u5411\u6570\u7ec4\u4e2d\u63d2\u5165\u5bf9\u8c61\n        students[0] = new Student(\"John\", 20);\n        students[1] = new Student(\"Mary\", 22);\n\n        \/\/ \u8bbf\u95ee\u6570\u7ec4\u4e2d\u7684\u5bf9\u8c61\n        Student student = students[0];\n        System.out.println(student.getName()); \/\/ \u8f93\u51fa \"John\"\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u628a\u5bf9\u8c61\u653e\u8fdb\u6570\u7ec4\u4e2d\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>\u5728 java \u4e2d\u53ef\u5c06\u5bf9\u8c61\u5b58\u5165\u6570\u7ec4\uff1a\u521b\u5efa\u6307\u5b9a\u7c7b\u578b\u5bf9\u8c61\u7684\u6570\u7ec4\uff0c\u5982 student[] students = new student[10];\u7528\u7d22\u5f15\u63d2\u5165\u5bf9\u8c61\uff0c\u5982 students[0] = student1;\u7528\u7d22\u5f15\u8bbf\u95ee\u5bf9\u8c61\uff0c\u5982 student student = students[0]; \u5982\u4f55\u5728 Java \u4e2d\u5c06\u5bf9\u8c61\u653e\u5165\u6570\u7ec4\u4e2d \u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u5c06\u5bf9\u8c61\u653e\u7f6e\u5728\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1a 1. \u521b\u5efa\u4e00\u4e2a\u6570\u7ec4 \u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u7c7b\u578b\u5bf9\u8c61\u7684\u6570\u7ec4\uff0c\u5176\u4e2d\u7c7b\u578b\u4e0e\u6240\u8981\u5b58\u50a8\u7684\u5bf9\u8c61\u4e00\u81f4\u3002\u4f8b\u5982\uff0c\u8981\u5b58\u50a8 Student \u7c7b\u7684\u5bf9\u8c61\uff0c\u5219\u9700\u8981\u521b\u5efa\u4ee5\u4e0b\u6570\u7ec4\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b Student[] students = new Student[10]; \u767b\u5f55\u540e\u590d\u5236 2. \u5411\u6570\u7ec4\u4e2d\u63d2\u5165\u5bf9\u8c61 \u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u7684\u7d22\u5f15\u6765\u5411\u5176\u4e2d\u63d2\u5165\u5bf9\u8c61\u3002\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u8868\u793a\u6570\u7ec4\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u3002\u4f8b\u5982\uff0c\u8981\u5411\u6570\u7ec4 students \u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u63d2\u5165\u4e00\u4e2a Student \u5bf9\u8c61 student1\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a students[0] = student1; \u767b\u5f55\u540e\u590d\u5236 3. \u8bbf\u95ee\u6570\u7ec4\u4e2d\u7684\u5bf9\u8c61 \u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u7684\u7d22\u5f15\u6765\u8bbf\u95ee\u5176\u5143\u7d20\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u6570\u7ec4 students \u4e2d\u7b2c\u4e00\u4e2a\u5143\u7d20\uff08\u7d22\u5f15\u4e3a 0\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a Student student [&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-38160","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38160","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=38160"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38160\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=38160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=38160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=38160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}