{"id":34538,"date":"2024-11-26T13:02:01","date_gmt":"2024-11-26T05:02:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/34538\/"},"modified":"2024-11-26T13:02:01","modified_gmt":"2024-11-26T05:02:01","slug":"java-%e4%b8%ad-%e8%bf%90%e7%ae%97%e7%ac%a6%e4%b8%ba%e4%bd%95%e8%83%bd%e9%9a%90%e5%bc%8f%e8%bd%ac%e6%8d%a2%ef%bc%8c%e8%80%8c%e7%9b%b4%e6%8e%a5%e8%b5%8b%e5%80%bc%e5%8d%b4%e4%bc%9a%e6%8a%a5%e9%94%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/34538\/","title":{"rendered":"Java \u4e2d += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u80fd\u9690\u5f0f\u8f6c\u6362\uff0c\u800c\u76f4\u63a5\u8d4b\u503c\u5374\u4f1a\u62a5\u9519\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173053424177191.jpg\" class=\"aligncenter\" title=\"Java \u4e2d += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u80fd\u9690\u5f0f\u8f6c\u6362\uff0c\u800c\u76f4\u63a5\u8d4b\u503c\u5374\u4f1a\u62a5\u9519\uff1f\u63d2\u56fe\" alt=\"Java \u4e2d += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u80fd\u9690\u5f0f\u8f6c\u6362\uff0c\u800c\u76f4\u63a5\u8d4b\u503c\u5374\u4f1a\u62a5\u9519\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>java += \u8fd0\u7b97\u7b26\u7684\u7591\u95ee<\/strong><\/p>\n<p>java \u4e2d\uff0c\u8d4b\u503c\u8fd0\u7b97\u7b26 += \u901a\u5e38\u4e0e\u57fa\u672c\u6570\u636e\u7c7b\u578b\u4e00\u8d77\u4f7f\u7528\uff0c\u7528\u4e8e\u7b80\u5316\u8d4b\u503c\u64cd\u4f5c\u3002\u4f8b\u5982\uff0cx+=1 \u7b49\u4ef7\u4e8e x = x+1\u3002\u4f46\u5f53\u4e0e\u6d6e\u70b9\u6570\u6216\u968f\u673a\u503c\u7b49\u590d\u6742\u8868\u8fbe\u5f0f\u4e00\u8d77\u4f7f\u7528\u65f6\uff0c\u5219\u9700\u8981\u6ce8\u610f\u4e00\u4e9b\u7279\u6b8a\u884c\u4e3a\u3002<\/p>\n<p><strong>x += math.random()*10 \u7684\u7279\u6b8a\u6027<\/strong><\/p>\n<p>\u8003\u8651\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>int x = 0;\nx += math.random() * 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u867d\u7136 x \u662f\u4e00\u4e2a int \u578b\u53d8\u91cf\uff0c\u4f46 math.random()<em>10 \u7684\u503c\u662f\u4e00\u4e2a\u6d6e\u70b9\u6570\u3002\u6839\u636e java \u89c4\u8303\uff0c+= \u8fd0\u7b97\u7b26\u5728\u6267\u884c\u65f6\u4f1a\u5f3a\u5236\u5c06\u53f3\u64cd\u4f5c\u6570\u8f6c\u6362\u4e3a\u5de6\u64cd\u4f5c\u6570\u7684\u7c7b\u578b\u3002\u8fd9\u610f\u5473\u7740\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0cmath.random()<\/em>10 \u5c06\u88ab\u5f3a\u5236\u8f6c\u6362\u4e3a int\uff0c\u5bfc\u81f4\u5c0f\u6570\u90e8\u5206\u88ab\u820d\u5f03\u3002\u56e0\u6b64\uff0cx \u5c06\u88ab\u8d4b\u503c\u4e3a\u4e00\u4e2a\u968f\u673a\u7684 int \u503c\uff0c\u4e0d\u4f1a\u62a5\u9519\u3002<\/p>\n<p><strong>x = x + math.random()*10 \u7684\u9519\u8bef<\/strong><\/p>\n<p>\u76f8\u53cd\uff0c\u5982\u679c\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fee\u6539\u4e3a\uff1a<\/p>\n<pre>x = x + Math.random() * 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5219\u4f1a\u4ea7\u751f\u4e00\u4e2a\u3002\u8fd9\u662f\u56e0\u4e3a x \u662f\u4e00\u4e2a int \u578b\u53d8\u91cf\uff0c\u800c x + math.random()*10 \u662f\u4e00\u4e2a\u6d6e\u70b9\u6570\u8868\u8fbe\u5f0f\u3002java \u4e0d\u5141\u8bb8\u5c06\u6d6e\u70b9\u6570\u76f4\u63a5\u8d4b\u503c\u7ed9 int \u578b\u53d8\u91cf\u3002<\/p>\n<p><strong>+= \u9690\u5f0f\u5f3a\u5236\u8f6c\u6362\u7684\u673a\u5236<\/strong><\/p>\n<p>+= \u8fd0\u7b97\u7b26\u7684\u9690\u5f0f\u5f3a\u5236\u8f6c\u6362\u673a\u5236\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u662f\u6709\u7528\u7684\uff0c\u53ef\u4ee5\u907f\u514d\u7f16\u5199\u989d\u5916\u7684\u4ee3\u7801\u6bb5\u6765\u8f6c\u6362\u6570\u636e\u7c7b\u578b\u3002\u4f46\u662f\uff0c\u5728\u4f7f\u7528\u8be5\u8fd0\u7b97\u7b26\u65f6\uff0c\u4e86\u89e3\u6f5c\u5728\u7684\u4e0d\u51c6\u786e\u6027\u975e\u5e38\u91cd\u8981\u3002\u4f8b\u5982\uff0c\u5f53\u5904\u7406\u6d6e\u70b9\u503c\u65f6\uff0c\u5f3a\u5236\u8f6c\u6362\u53ef\u80fd\u4f1a\u5bfc\u81f4\u7cbe\u5ea6\u635f\u5931\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5728\u4f7f\u7528 += \u8fd0\u7b97\u7b26\u65f6\uff0c\u9700\u8981\u6743\u8861\u5176\u4fbf\u5229\u6027\u4e0e\u6f5c\u5728\u7684\u4e0d\u51c6\u786e\u6027\uff0c\u5e76\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u505a\u51fa\u6700\u4f18\u9009\u62e9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJava \u4e2d += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u80fd\uff0c\u800c\u76f4\u63a5\u8d4b\u503c\u5374\u4f1a\u62a5\u9519\uff1f\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>java += \u8fd0\u7b97\u7b26\u7684\u7591\u95ee java \u4e2d\uff0c\u8d4b\u503c\u8fd0\u7b97\u7b26 += \u901a\u5e38\u4e0e\u57fa\u672c\u6570\u636e\u7c7b\u578b\u4e00\u8d77\u4f7f\u7528\uff0c\u7528\u4e8e\u7b80\u5316\u8d4b\u503c\u64cd\u4f5c\u3002\u4f8b\u5982\uff0cx+=1 \u7b49\u4ef7\u4e8e x = x+1\u3002\u4f46\u5f53\u4e0e\u6d6e\u70b9\u6570\u6216\u968f\u673a\u503c\u7b49\u590d\u6742\u8868\u8fbe\u5f0f\u4e00\u8d77\u4f7f\u7528\u65f6\uff0c\u5219\u9700\u8981\u6ce8\u610f\u4e00\u4e9b\u7279\u6b8a\u884c\u4e3a\u3002 x += math.random()*10 \u7684\u7279\u6b8a\u6027 \u8003\u8651\u4ee5\u4e0b\u4ee3\u7801\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b int x = 0; x += math.random() * 10; \u767b\u5f55\u540e\u590d\u5236 \u867d\u7136 x \u662f\u4e00\u4e2a int \u578b\u53d8\u91cf\uff0c\u4f46 math.random()10 \u7684\u503c\u662f\u4e00\u4e2a\u6d6e\u70b9\u6570\u3002\u6839\u636e java \u89c4\u8303\uff0c+= \u8fd0\u7b97\u7b26\u5728\u6267\u884c\u65f6\u4f1a\u5f3a\u5236\u5c06\u53f3\u64cd\u4f5c\u6570\u8f6c\u6362\u4e3a\u5de6\u64cd\u4f5c\u6570\u7684\u7c7b\u578b\u3002\u8fd9\u610f\u5473\u7740\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0cmath.random()10 \u5c06\u88ab\u5f3a\u5236\u8f6c\u6362\u4e3a int\uff0c\u5bfc\u81f4\u5c0f\u6570\u90e8\u5206\u88ab\u820d\u5f03\u3002\u56e0\u6b64\uff0cx \u5c06\u88ab\u8d4b\u503c\u4e3a\u4e00\u4e2a\u968f\u673a\u7684 int \u503c\uff0c\u4e0d\u4f1a\u62a5\u9519\u3002 x = x + math.random()*10 \u7684\u9519\u8bef \u76f8\u53cd\uff0c\u5982\u679c\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fee\u6539\u4e3a\uff1a x = x + Math.random() * [&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-34538","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34538","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=34538"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34538\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=34538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=34538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=34538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}