{"id":836,"date":"2022-10-10T22:44:45","date_gmt":"2022-10-10T14:44:45","guid":{"rendered":"https:\/\/qaqaq.top\/?p=836"},"modified":"2022-11-27T12:39:54","modified_gmt":"2022-11-27T04:39:54","slug":"%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1%e4%b8%8b-static%e8%af%be%e5%90%8e%e7%bb%83%e4%b9%a0%ef%bc%9a%e8%b4%a6%e6%88%b7%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=836","title":{"rendered":"\u9762\u5411\u5bf9\u8c61(\u4e0b)-static\u8bfe\u540e\u7ec3\u4e60\uff1a\u8d26\u6237\u4fe1\u606f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P323;\r\n\r\n\/*\r\n * \u7f16\u5199\u4e00\u4e2a\u7c7b\u5b9e\u73b0\u94f6\u884c\u8d26\u6237\u7684\u6982\u5ff5\uff0c\u5305\u542b\u7684\u5c5e\u6027\u6709\u201c\u5e10\u53f7\u201d\u3001\u201c\u5bc6\u7801\u201d\u3001\u201c\u5b58\u6b3e\u4f59\u989d\u201d\u3001\u201c\u5229\u7387\u201d\u3001\u201c\u6700\u5c0f\u4f59\u989d\u201d\uff0c\r\n * \u5b9a\u4e49\u5c01\u88c5\u8fd9\u4e9b\u5c5e\u6027\u7684\u65b9\u6cd5\u3002\u8d26\u53f7\u8981\u81ea\u52a8\u751f\u6210\u3002\r\n * \u7f16\u5199\u4e3b\u7c7b\uff0c\u4f7f\u7528\u94f6\u884c\u8d26\u6237\u7c7b\uff0c\u8f93\u5165\u3001\u8f93\u51fa3\u4e2a\u50a8\u6237\u7684\u4e0a\u8ff0\u4fe1\u606f\u3002\r\n * \u8003\u8651\uff1a\u54ea\u4e9b\u5c5e\u6027\u53ef\u4ee5\u8bbe\u8ba1\u6210static\u5c5e\u6027\u3002\r\n * \r\n * \r\n * \r\n * \r\n *\/\r\npublic class Account {\r\n\r\n\tprivate int id;\r\n\tprivate String pwd = \"000000\";\r\n\tprivate double balance;\r\n\r\n\tprivate static double interestRate;\r\n\tprivate static double minMoney = 1.0;\r\n\tprivate static int init = 1001;\/\/ \u7528\u4e8e\u81ea\u52a8\u751f\u6210id\u4f7f\u7528\u7684\r\n\r\n\tpublic Account() {\r\n\t\tid = init++;\r\n\t}\r\n\t\r\n\tpublic Account(String pwd,double balance) {\r\n\t\tid = init++;\r\n\t\tthis.pwd = pwd;\r\n\t\tthis.balance = balance;\r\n\t}\r\n\t\r\n\tpublic String getPwd() {\r\n\t\treturn pwd;\r\n\t}\r\n\r\n\tpublic void setPwd(String pwd) {\r\n\t\tthis.pwd = pwd;\r\n\t}\r\n\r\n\tpublic static double getInterestRate() {\r\n\t\treturn interestRate;\r\n\t}\r\n\r\n\tpublic static void setInterestRate(double interestRate) {\r\n\t\tAccount.interestRate = interestRate;\r\n\t}\r\n\r\n\tpublic static double getMinMoney() {\r\n\t\treturn minMoney;\r\n\t}\r\n\r\n\tpublic static void setMinMoney(double minMoney) {\r\n\t\tAccount.minMoney = minMoney;\r\n\t}\r\n\r\n\tpublic int getId() {\r\n\t\treturn id;\r\n\t}\r\n\r\n\tpublic double getBalance() {\r\n\t\treturn balance;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic String toString() {\r\n\t\treturn \"Account &#91;id=\" + id + \", pwd=\" + pwd + \", balance=\" + balance + \"]\";\r\n\t}\r\n\t\r\n\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P323;\r\n\/*\r\n * \u7f16\u5199\u4e00\u4e2a\u7c7b\u5b9e\u73b0\u94f6\u884c\u8d26\u6237\u7684\u6982\u5ff5\uff0c\u5305\u542b\u7684\u5c5e\u6027\u6709\u201c\u5e10\u53f7\u201d\u3001\u201c\u5bc6\u7801\u201d\u3001\u201c\u5b58\u6b3e\u4f59\u989d\u201d\u3001\u201c\u5229\u7387\u201d\u3001\u201c\u6700\u5c0f\u4f59\u989d\u201d\uff0c\r\n * \u5b9a\u4e49\u5c01\u88c5\u8fd9\u4e9b\u5c5e\u6027\u7684\u65b9\u6cd5\u3002\u8d26\u53f7\u8981\u81ea\u52a8\u751f\u6210\u3002\r\n * \u7f16\u5199\u4e3b\u7c7b\uff0c\u4f7f\u7528\u94f6\u884c\u8d26\u6237\u7c7b\uff0c\u8f93\u5165\u3001\u8f93\u51fa3\u4e2a\u50a8\u6237\u7684\u4e0a\u8ff0\u4fe1\u606f\u3002\r\n * \u8003\u8651\uff1a\u54ea\u4e9b\u5c5e\u6027\u53ef\u4ee5\u8bbe\u8ba1\u6210static\u5c5e\u6027\u3002\r\n * \r\n * \r\n * \r\n * \r\n *\/\r\npublic class AcountTest {\r\n\t\r\n\tpublic static void main(String&#91;] args) {\r\n\t\t\r\n\t\tAccount acct1 = new Account();\r\n\t\tAccount acct2 = new Account(\"qwerty\", 2000);\r\n\t\t\r\n\t\tAccount.setInterestRate(0.012);\r\n\t\tAccount.setMinMoney(100);\r\n\t\t\r\n\t\tSystem.out.println(acct1);\r\n\t\tSystem.out.println(acct2);\r\n\t\t\r\n\t\tSystem.out.println(acct1.getInterestRate());\r\n\t\tSystem.out.println(acct1.getMinMoney());\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[46],"class_list":["post-836","post","type-post","status-publish","format-standard","hentry","category-java-code","tag-java"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/836"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=836"}],"version-history":[{"count":1,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/836\/revisions"}],"predecessor-version":[{"id":837,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/836\/revisions\/837"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}