{"id":35051,"date":"2024-11-26T10:30:33","date_gmt":"2024-11-26T02:30:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/35051\/"},"modified":"2024-11-26T10:30:33","modified_gmt":"2024-11-26T02:30:33","slug":"java-%e8%bf%90%e7%ae%97%e7%ac%a6%e4%b8%ba%e4%bd%95%e5%af%b9%e6%b5%ae%e7%82%b9%e6%95%b0%e6%9c%89%e7%89%b9%e6%ae%8a%e8%a1%8c%e4%b8%ba%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/35051\/","title":{"rendered":"Java += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u5bf9\u6d6e\u70b9\u6570\u6709\u7279\u6b8a\u884c\u4e3a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173059597947325.jpg\" class=\"aligncenter\" title=\"Java += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u5bf9\u6d6e\u70b9\u6570\u6709\u7279\u6b8a\u884c\u4e3a\uff1f\u63d2\u56fe\" alt=\"Java += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u5bf9\u6d6e\u70b9\u6570\u6709\u7279\u6b8a\u884c\u4e3a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>Java += \u7684\u8ff7\u60d1<\/strong><\/p>\n<p>\u5bf9\u4e8e Java \u4e2d\u7684 += \u8fd0\u7b97\u7b26\uff0c\u6211\u4eec\u5e38\u8ba4\u4e3a\u5b83\u7b49\u540c\u4e8e x = x + 1\u3002\u7136\u800c\uff0c\u5f53\u6d89\u53ca\u5230\u6d6e\u70b9\u6570\u65f6\uff0c\u60c5\u51b5\u53d8\u5f97\u6709\u4e9b\u590d\u6742\u3002\u8ba9\u6211\u4eec\u63a2\u8ba8 x += Math.random() <em> 10; \u4e0e x = x + Math.random() <\/em> 10; \u8fd9\u4e24\u4e2a\u8868\u8fbe\u5f0f\u7684\u5dee\u5f02\u3002<\/p>\n<p>\u7b2c\u4e00\u4e2a\u8868\u8fbe\u5f0f\u6ca1\u95ee\u9898\uff0c\u800c\u7b2c\u4e8c\u4e2a\u8868\u8fbe\u5f0f\u5728 x \u4e3a int \u7c7b\u578b\u65f6\u4f1a\u62a5\u9519\u3002\u8fd9\u662f\u56e0\u4e3a += \u8fd0\u7b97\u7b26\u6709\u4e00\u4e2a\u9690\u85cf\u7279\u6027\uff1a\u5728\u4f7f\u7528\u5b83\u65f6\uff0c\u4f1a\u9690\u5f0f\u6267\u884c\u4e00\u6b21\u7c7b\u578b\u8f6c\u6362\u3002<\/p>\n<p>\u5f53\u4f7f\u7528 += \u8fd0\u7b97\u7b26\u65f6\uff0c\u5b83\u4f1a\u5c06\u8868\u8fbe\u5f0f\u53f3\u4fa7\u7684\u64cd\u4f5c\u6570\u8f6c\u6362\u4e3a\u4e0e\u5de6\u4fa7\u64cd\u4f5c\u6570\u76f8\u540c\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5728 x += Math.random() <em> 10; \u4e2d\uff0cMath.random() <\/em> 10 \u8fd4\u56de\u4e00\u4e2a double \u503c\uff0c\u800c x \u662f int \u7c7b\u578b\u3002\u901a\u8fc7\u4f7f\u7528 +=\uff0cJava \u4f1a\u81ea\u52a8\u5c06 Math.random() * 10 \u8f6c\u6362\u4e3a int\uff0c\u4f7f\u5176\u4e0e x \u76f8\u540c\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u7136\u800c\uff0c\u5f53\u4f7f\u7528 x = x + Math.random() <em> 10; \u65f6\uff0c\u4e0d\u4f1a\u8fdb\u884c\u3002x \u662f int \u7c7b\u578b\uff0c\u800c Math.random() <\/em> 10 \u8fd4\u56de double \u503c\u3002\u56e0\u6b64\uff0c\u7f16\u8bd1\u5668\u4f1a\u62a5\u544a\u7c7b\u578b\u4e0d\u5339\u914d\u7684\u9519\u8bef\u3002<\/p>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u79cd\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u6709\u65f6\u662f\u6709\u76ca\u7684\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u7b80\u5316\u4ee3\u7801\u5e76\u63d0\u9ad8\u6548\u7387\u3002\u4f46\u662f\uff0c\u5b83\u4e5f\u53ef\u80fd\u5bfc\u81f4\u7cbe\u5ea6\u635f\u5931\u548c\u5176\u4ed6\u610f\u5916\u60c5\u51b5\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528 += \u8fd0\u7b97\u7b26\u5904\u7406\u6d6e\u70b9\u6570\u65f6\uff0c\u4e86\u89e3\u5176\u9690\u85cf\u7279\u6027\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJava += \u8fd0\u7b97\u7b26\u4e3a\u4f55\u5bf9\u6d6e\u70b9\u6570\u6709\u7279\u6b8a\u884c\u4e3a\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 += \u7684\u8ff7\u60d1 \u5bf9\u4e8e Java \u4e2d\u7684 += \u8fd0\u7b97\u7b26\uff0c\u6211\u4eec\u5e38\u8ba4\u4e3a\u5b83\u7b49\u540c\u4e8e x = x + 1\u3002\u7136\u800c\uff0c\u5f53\u6d89\u53ca\u5230\u6d6e\u70b9\u6570\u65f6\uff0c\u60c5\u51b5\u53d8\u5f97\u6709\u4e9b\u590d\u6742\u3002\u8ba9\u6211\u4eec\u63a2\u8ba8 x += Math.random() 10; \u4e0e x = x + Math.random() 10; \u8fd9\u4e24\u4e2a\u8868\u8fbe\u5f0f\u7684\u5dee\u5f02\u3002 \u7b2c\u4e00\u4e2a\u8868\u8fbe\u5f0f\u6ca1\u95ee\u9898\uff0c\u800c\u7b2c\u4e8c\u4e2a\u8868\u8fbe\u5f0f\u5728 x \u4e3a int \u7c7b\u578b\u65f6\u4f1a\u62a5\u9519\u3002\u8fd9\u662f\u56e0\u4e3a += \u8fd0\u7b97\u7b26\u6709\u4e00\u4e2a\u9690\u85cf\u7279\u6027\uff1a\u5728\u4f7f\u7528\u5b83\u65f6\uff0c\u4f1a\u9690\u5f0f\u6267\u884c\u4e00\u6b21\u7c7b\u578b\u8f6c\u6362\u3002 \u5f53\u4f7f\u7528 += \u8fd0\u7b97\u7b26\u65f6\uff0c\u5b83\u4f1a\u5c06\u8868\u8fbe\u5f0f\u53f3\u4fa7\u7684\u64cd\u4f5c\u6570\u8f6c\u6362\u4e3a\u4e0e\u5de6\u4fa7\u64cd\u4f5c\u6570\u76f8\u540c\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5728 x += Math.random() 10; \u4e2d\uff0cMath.random() 10 \u8fd4\u56de\u4e00\u4e2a double \u503c\uff0c\u800c x \u662f int \u7c7b\u578b\u3002\u901a\u8fc7\u4f7f\u7528 +=\uff0cJava \u4f1a\u81ea\u52a8\u5c06 Math.random() * 10 \u8f6c\u6362\u4e3a int\uff0c\u4f7f\u5176\u4e0e [&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-35051","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35051","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=35051"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35051\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=35051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=35051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=35051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}