{"id":2344,"date":"2025-11-21T20:35:13","date_gmt":"2025-11-21T12:35:13","guid":{"rendered":"https:\/\/zhenti.52daan.com\/?p=2344"},"modified":"2025-11-21T20:35:13","modified_gmt":"2025-11-21T12:35:13","slug":"%e7%bb%99%e5%87%ba%e4%b8%8b%e9%9d%a2%e7%9a%84%e4%b8%8d%e5%ae%8c%e6%95%b4%e7%9a%84%e7%b1%bb%e4%bb%a3%e7%a0%81%ef%bc%9a-class-person-string-name-department-int-age-public-personstring-n-name-n","status":"publish","type":"post","link":"https:\/\/zhenti.52daan.com\/?p=2344","title":{"rendered":"\u7ed9\u51fa\u4e0b\u9762\u7684\u4e0d\u5b8c\u6574\u7684\u7c7b\u4ee3\u7801\uff1a class Person { String name, department; int age; public Person(String n){ name = n; } public Person(String n, int a){ name = n; age = a; } public Person(String n, String d, int a) { \/\/ doing the same as two arguments version of constructor \/\/ including assignment name=n,age=a department = d; } } \u4e0b\u9762\u7684\u54ea\u4e9b\u8868\u8fbe\u5f0f\u53ef\u4ee5\u52a0\u5230\u6784\u9020\u65b9\u6cd5\u4e2d\u7684&#8221;doing the same as&#8230;&#8221;\u5904\uff1f A.this(n,a); B.this(name,age); C.name=n;age=a; D.Person(n,a);"},"content":{"rendered":"<p>\u7ed9\u51fa\u4e0b\u9762\u7684\u4e0d\u5b8c\u6574\u7684\u7c7b\u4ee3\u7801\uff1a class Person { String name, department; int age; public Person(String n){ name = n; } public Person(String n, int a){ name = n; age = a; } public Person(String n, String d, int a) { \/\/ doing the same as two arguments version of constructor \/\/ including assignment name=n,age=a department = d; } } \u4e0b\u9762\u7684\u54ea\u4e9b\u8868\u8fbe\u5f0f\u53ef\u4ee5\u52a0\u5230\u6784\u9020\u65b9\u6cd5\u4e2d\u7684&#8221;doing the same as&#8230;&#8221;\u5904\uff1f A.this(n,a); B.this(name,age); C.name=n;age=a; D.Person(n,a);<\/p>\n<p>\u6b63\u786e\u7b54\u6848\uff1aAC<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u51fa\u4e0b\u9762\u7684\u4e0d\u5b8c\u6574\u7684\u7c7b\u4ee3\u7801\uff1a cl&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[94],"class_list":["post-2344","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-java"],"_links":{"self":[{"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=\/wp\/v2\/posts\/2344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2344"}],"version-history":[{"count":0,"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=\/wp\/v2\/posts\/2344\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhenti.52daan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}