{"id":65584,"date":"2025-05-03T09:18:37","date_gmt":"2025-05-03T01:18:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65584\/"},"modified":"2025-05-03T09:18:37","modified_gmt":"2025-05-03T01:18:37","slug":"java%e5%a4%8d%e6%95%b0%e7%9a%84%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e5%88%9b%e5%bb%ba-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65584\/","title":{"rendered":"java\u590d\u6570\u7684\u6570\u7ec4\u600e\u4e48\u521b\u5efa"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u521b\u5efa\u590d\u6570\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a1. \u4f7f\u7528 complex \u7c7b\u521b\u5efa complex[] \u6570\u7ec4\u30022. \u521b\u5efa\u81ea\u5b9a\u4e49\u7c7b\uff0c\u4f8b\u5982 mycomplex\uff0c\u5e76\u521b\u5efa mycomplex[] \u6570\u7ec4\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111304335725064.jpg\" class=\"aligncenter\" title=\"java\u590d\u6570\u7684\u6570\u7ec4\u600e\u4e48\u521b\u5efa\u63d2\u56fe\" alt=\"java\u590d\u6570\u7684\u6570\u7ec4\u600e\u4e48\u521b\u5efa\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u590d\u6570\u6570\u7ec4\u521b\u5efa<\/strong><\/p>\n<p>\u5728 Java \u4e2d\u521b\u5efa\u590d\u6570\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 Complex \u7c7b<\/strong><\/p>\n<p>Complex \u7c7b\u662f Java \u4e2d\u8868\u793a\u590d\u6570\u7684\u5185\u7f6e\u7c7b\u3002\u8981\u521b\u5efa\u590d\u6570\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528 Complex[] \u6570\u7ec4\u7c7b\u578b\u3002\u4f8b\u5982\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>Complex[] complexArray = new Complex[3];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Complex() \u6784\u9020\u51fd\u6570\u6216 valueOf() \u65b9\u6cd5\u4e3a\u6570\u7ec4\u5143\u7d20\u8d4b\u503c\u3002<\/p>\n<pre>complexArray[0] = new Complex(1, 2);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528\u81ea\u5b9a\u4e49\u7c7b<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u66f4\u7075\u6d3b\u7684\u5b9e\u73b0\uff0c\u4e5f\u53ef\u4ee5\u521b\u5efa\u81ea\u5df1\u7684\u590d\u6570\u7c7b\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>public class MyComplex {\n    private double real;\n    private double imaginary;\n\n    public MyComplex(double real, double imaginary) {\n        this.real = real;\n        this.imaginary = imaginary;\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a MyComplex[] \u6570\u7ec4\u5e76\u50cf\u4f7f\u7528\u5185\u7f6e Complex \u7c7b\u4e00\u6837\u8d4b\u503c\u3002<\/p>\n<pre>MyComplex[] myComplexArray = new MyComplex[3];\nmyComplexArray[0] = new MyComplex(1, 2);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u590d\u6570\u7684\u6570\u7ec4\u600e\u4e48\u521b\u5efa\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\u521b\u5efa\u590d\u6570\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a1. \u4f7f\u7528 complex \u7c7b\u521b\u5efa complex[] \u6570\u7ec4\u30022. \u521b\u5efa\u81ea\u5b9a\u4e49\u7c7b\uff0c\u4f8b\u5982 mycomplex\uff0c\u5e76\u521b\u5efa mycomplex[] \u6570\u7ec4\u3002 Java \u590d\u6570\u6570\u7ec4\u521b\u5efa \u5728 Java \u4e2d\u521b\u5efa\u590d\u6570\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a 1. \u4f7f\u7528 Complex \u7c7b Complex \u7c7b\u662f Java \u4e2d\u8868\u793a\u590d\u6570\u7684\u5185\u7f6e\u7c7b\u3002\u8981\u521b\u5efa\u590d\u6570\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528 Complex[] \u6570\u7ec4\u7c7b\u578b\u3002\u4f8b\u5982\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b Complex[] complexArray = new Complex[3]; \u767b\u5f55\u540e\u590d\u5236 \u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Complex() \u6784\u9020\u51fd\u6570\u6216 valueOf() \u65b9\u6cd5\u4e3a\u6570\u7ec4\u5143\u7d20\u8d4b\u503c\u3002 complexArray[0] = new Complex(1, 2); \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528\u81ea\u5b9a\u4e49\u7c7b \u5982\u679c\u60a8\u9700\u8981\u66f4\u7075\u6d3b\u7684\u5b9e\u73b0\uff0c\u4e5f\u53ef\u4ee5\u521b\u5efa\u81ea\u5df1\u7684\u590d\u6570\u7c7b\u3002\u4f8b\u5982\uff1a public class MyComplex { private double real; private [&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-65584","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65584","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=65584"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65584\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}