{"id":36491,"date":"2024-11-26T12:28:47","date_gmt":"2024-11-26T04:28:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/36491\/"},"modified":"2024-11-26T12:28:47","modified_gmt":"2024-11-26T04:28:47","slug":"%e4%bd%bf%e7%94%a8%e4%b8%80%e5%85%83%e8%bf%90%e7%ae%97%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/36491\/","title":{"rendered":"\u4f7f\u7528\u4e00\u5143\u8fd0\u7b97\u7b26"},"content":{"rendered":"<p>\u6839\u636e\u5b9a\u4e49\uff0c\u4e00\u5143\u8fd0\u7b97\u7b26\u662f\u53ea\u9700\u8981\u4e00\u4e2a\u64cd\u4f5c\u6570\u6216\u53d8\u91cf\u6765<br \/> \u51fd\u6570\u3002\u5b83\u4eec\u7ecf\u5e38\u6267\u884c\u7b80\u5355\u7684\u4efb\u52a1\uff0c\u4f8b\u5982\u589e\u52a0<br \/> \u6570\u503c\u53d8\u91cf\u51cf\u4e00\uff0c\u6216\u5bf9\u5e03\u5c14\u503c\u6c42\u8d1f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173121697275039.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528\u4e00\u5143\u8fd0\u7b97\u7b26\u63d2\u56fe\" alt=\"\u4f7f\u7528\u4e00\u5143\u8fd0\u7b97\u7b26\u63d2\u56fe\" \/><\/p>\n<p><strong>\u903b\u8f91\u8865\u7801\u548c\u5426\u5b9a\u8fd0\u7b97\u7b26<\/strong><br \/><em>\u903b\u8f91\u8865\u8fd0\u7b97\u7b26<\/em> !\uff0c\u7ffb\u8f6c\u5e03\u5c14\u8868\u8fbe\u5f0f\u7684\u503c\u3002\u4f8b\u5982\uff0c<br \/> \u5982\u679c\u503c\u4e3a true\uff0c\u5219\u5c06\u5176\u8f6c\u6362\u4e3a false\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002\u4e3a\u4e86\u8bf4\u660e\u8fd9\u4e00\u70b9\uff0c\u8bf7\u6bd4\u8f83<br \/> \u4ee5\u4e0b\u8bed\u53e5\u7684\u8f93\u51fa\uff1a<\/p>\n<pre>boolean x = false;\nsystem.out.println(x); \/\/ false\nx = !x;\nsystem.out.println(x); \/\/ true\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><em>\u540c\u6837\uff0c\u5426\u5b9a\u8fd0\u7b97\u7b26<\/em>\uff0c-\uff0c\u53cd\u8f6c\u6570\u503c\u8868\u8fbe\u5f0f\u7684\u7b26\u53f7\uff0c\u5982\u56fe<br \/> \u5728\u8fd9\u4e9b\u58f0\u660e\u4e2d\uff1a<\/p>\n<pre>double x = 1.21;\nsystem.out.println(x); \/\/ 1.21\nx = -x;\nsystem.out.println(x); \/\/ -1.21\nx = -x;\nsystem.out.println(x); \/\/ 1.21\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6839\u636e\u63cf\u8ff0\uff0c\u5f88\u660e\u663e\u67d0\u4e9b\u8fd0\u7b97\u7b26\u9700\u8981\u53d8\u91cf<br \/> \u6216\u4ed6\u4eec\u6b63\u5728\u91c7\u53d6\u884c\u52a8\u7684\u7279\u5b9a\u7c7b\u578b\u7684\u8868\u8fbe\u3002\u4f8b\u5982\uff0c\u60a8\u4e0d\u80fd\u7533\u8bf7<br \/> \u5426\u5b9a\u8fd0\u7b97\u7b26 &#8211; \u5e94\u7528\u4e8e\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u4e5f\u4e0d\u80fd\u5e94\u7528\u903b\u8f91\u8865<br \/> \u8fd0\u7b97\u7b26 ! \u5230\u6570\u503c\u8868\u8fbe\u5f0f\u3002\u8b66\u60d5\u8003\u8bd5\u4e2d\u8bd5\u56fe\u8fd9\u6837\u505a\u7684\u95ee\u9898\uff0c<br \/> \u56e0\u4e3a\u5b83\u4eec\u4f1a\u5bfc\u81f4\u4ee3\u7801\u65e0\u6cd5\u7f16\u8bd1\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u4ee3\u7801\u884c\u90fd\u6ca1\u6709<br \/> \u5c06\u7f16\u8bd1\uff1a<\/p>\n<pre>int x = !5; \/\/ does not compile\nboolean y = -true; \/\/ does not compile\nboolean z = !0; \/\/ does not compile\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7b2c\u4e00\u4e2a\u8bed\u53e5\u4e0d\u4f1a\u7f16\u8bd1\uff0c\u56e0\u4e3a\u5728 java \u4e2d\u4f60\u65e0\u6cd5\u6267\u884c<br \/> \u6570\u503c\u7684\u903b\u8f91\u53cd\u8f6c\u3002\u7b2c\u4e8c\u6761\u8bed\u53e5\u65e0\u6cd5\u7f16\u8bd1\uff0c\u56e0\u4e3a\u60a8<br \/> \u65e0\u6cd5\u5bf9\u5e03\u5c14\u503c\u8fdb\u884c\u6570\u503c\u6c42\u53cd\uff1b\u60a8\u9700\u8981\u4f7f\u7528\u903b\u8f91\u9006\u8fd0\u7b97\u7b26\u3002<br \/> \u6700\u540e\uff0c\u6700\u540e\u4e00\u6761\u8bed\u53e5\u65e0\u6cd5\u7f16\u8bd1\uff0c\u56e0\u4e3a\u60a8\u65e0\u6cd5\u83b7\u53d6\u6570\u503c\u7684\u903b\u8f91\u8865\u7801\uff0c\u4e5f\u65e0\u6cd5\u5c06\u6574\u6570\u5206\u914d\u7ed9\u5e03\u5c14\u53d8\u91cf\u3002<\/p>\n<blockquote><p>\n  \u5728 java 1 \u4e2d\u548c true \u5728\u4e2d\u6ca1\u6709\u5173\u7cfb \u65e0\u8bba\u5982\u4f55\uff0c\u5c31\u50cf 0 \u548c false \u6ca1\u6709\u5173\u7cfb\u4e00\u6837\u3002 \u81ea\u589e\u548c\u81ea\u51cf\u8fd0\u7b97\u7b26 \u9012\u589e\u548c\u9012\u51cf\u8fd0\u7b97\u7b26 ++ \u548c &#8212; \u5206\u522b\u53ef\u4ee5\u5e94\u7528\u4e8e\u6570\u5b57 \u4e0e\u4e8c\u5143\u8fd0\u7b97\u7b26\u76f8\u6bd4\uff0c\u64cd\u4f5c\u6570 \u548c \u5177\u6709\u66f4\u9ad8\u7684\u987a\u5e8f\u6216\u4f18\u5148\u7ea7\u3002\u5728 \u6362\u53e5\u8bdd\u8bf4\uff0c\u5b83\u4eec\u901a\u5e38\u9996\u5148\u5e94\u7528\u4e8e\u8868\u8fbe\u5f0f\u3002 \u81ea\u589e\u548c\u81ea\u51cf\u8fd0\u7b97\u7b26\u9700\u8981\u7279\u522b\u5c0f\u5fc3\uff0c\u56e0\u4e3a\u5b83\u4eec\u7684\u987a\u5e8f \u5e94\u7528\u4e8e\u76f8\u5173\u64cd\u4f5c\u6570\u53ef\u4ee5\u6539\u53d8\u8868\u8fbe\u5f0f\u7684\u5904\u7406\u65b9\u5f0f\u3002\u5982\u679c\u8fd0\u7b97\u7b26\u653e\u5728\u64cd\u4f5c\u6570\u4e4b\u524d\uff0c\u79f0\u4e3a\u9884\u81ea\u589e\u8fd0\u7b97\u7b26\u548c\u9884\u81ea\u51cf\u8fd0\u7b97\u7b26\uff0c\u5219\u9996\u5148\u5e94\u7528\u8fd0\u7b97\u7b26\u5e76\u8fd4\u56de\u503c \u662f\u8868\u8fbe\u5f0f\u7684\u65b0\u503c\u3002\u6216\u8005\uff0c\u5982\u679c\u8fd0\u7b97\u7b26\u4f4d\u4e8e\u64cd\u4f5c\u6570\u4e4b\u540e\uff0c \u79f0\u4e3a\u540e\u81ea\u589e\u8fd0\u7b97\u7b26\u548c\u540e\u81ea\u51cf\u8fd0\u7b97\u7b26\uff0c\u5219\u8fd4\u56de\u8868\u8fbe\u5f0f\u7684\u539f\u59cb\u503c\uff0c\u8fd4\u56de\u503c\u540e\u5e94\u7528\u8fd0\u7b97\u7b26 \u8fd9\u662f\u793a\u4f8b\u56fe\uff1a\n<\/p><\/blockquote>\n<pre>int counter = 0;\nsystem.out.println(counter); \/\/ outputs 0\nsystem.out.println(++counter); \/\/ outputs 1\nsystem.out.println(counter); \/\/ outputs 1\nsystem.out.println(counter--); \/\/ outputs 1\nsystem.out.println(counter); \/\/ outputs 0\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7b2c\u4e00\u4e2a\u9884\u81ea\u589e\u8fd0\u7b97\u7b26\u66f4\u65b0\u8ba1\u6570\u5668\u7684\u503c\u5e76\u8f93\u51fa\u65b0\u7684<br \/> \u503c\u4e3a 1\u3002\u4e0b\u4e00\u4e2a\u540e\u9012\u51cf\u8fd0\u7b97\u7b26\u4e5f\u4f1a\u66f4\u65b0 counter \u7684\u503c\uff0c\u4f46\u8f93\u51fa<br \/> \u9012\u51cf\u53d1\u751f\u4e4b\u524d\u7684\u503c\u3002<br \/> \u8ba4\u8bc1\u8003\u8bd5\u4e2d\u7684\u4e00\u79cd\u5e38\u89c1\u505a\u6cd5\uff08\u5c3d\u7ba1\u5728\u73b0\u5b9e\u4e16\u754c\u4e2d\u4e0d\u592a\u5e38\u89c1\uff09\u662f<br \/> \u5c06\u591a\u4e2a\u9012\u589e\u6216\u9012\u51cf\u8fd0\u7b97\u7b26\u5e94\u7528\u4e8e\u540c\u4e00\u884c\u4e0a\u7684\u5355\u4e2a\u53d8\u91cf\uff1a<\/p>\n<pre>int x = 3;\nint y = ++x * 5 \/ x-- + --x;\nsystem.out.println(\"x is \" + x);\nsystem.out.println(\"y is \" + y);\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u4e2a\u6bd4\u4e0a\u4e00\u4e2a\u4f8b\u5b50\u66f4\u590d\u6742\uff0c\u56e0\u4e3a x \u88ab\u4fee\u6539\u4e86\u4e09\u4e2a<br \/> \u591a\u6b21\u5728\u540c\u4e00\u6761\u7ebf\u4e0a\u3002\u6bcf\u6b21\u4fee\u6539\u65f6\uff0c\u968f\u7740\u8868\u8fbe\u5f0f\u4ece\u5de6\u5411\u53f3\u79fb\u52a8\uff0c<br \/> x \u7684\u503c\u53d1\u751f\u53d8\u5316\uff0c\u4e3a\u53d8\u91cf\u5206\u914d\u4e86\u4e0d\u540c\u7684\u503c\u3002\u6b63\u5982\u4f60\u6240\u8bb0\u5f97\u7684<br \/> \u4ece\u6211\u4eec\u5bf9\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u7684\u8ba8\u8bba\u6765\u770b\uff0c\u8fd0\u7b97\u987a\u5e8f\u5728<br \/>\u4e2d\u8d77\u7740\u91cd\u8981\u4f5c\u7528 \u8bc4\u4f30\u8fd9\u4e2a\u4f8b\u5b50\u3002<br \/> \u90a3\u4e48\u5982\u4f55\u9605\u8bfb\u8fd9\u6bb5\u4ee3\u7801\u5462\uff1f\u9996\u5148\uff0cx \u9012\u589e\u5e76\u8fd4\u56de\u8868\u8fbe\u5f0f\uff0c<br \/> \u4e58\u4ee5 5\u3002\u6211\u4eec\u53ef\u4ee5\u7b80\u5316\u5b83\uff1a<\/p>\n<pre>int y = 4 * 5 \/ x-- + --x; \/\/ x assigned value of 4\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u63a5\u4e0b\u6765\uff0cx \u9012\u51cf\uff0c\u4f46\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u4e86\u539f\u59cb\u503c 4\uff0c\u5bfc\u81f4<br \/> \u8fd9\u4e2a\uff1a<\/p>\n<pre>int y = 4 * 5 \/ 4 + --x; \/\/ x assigned value of 3\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>x \u7684\u6700\u7ec8\u8d4b\u503c\u5c06\u503c\u51cf\u5c11\u4e3a 2\uff0c\u5e76\u4e14\u7531\u4e8e\u8fd9\u662f\u4e00\u4e2a\u9884\u81ea\u589e\u8fd0\u7b97\u7b26\uff0c\u56e0\u6b64\u8be5\u503c\u5c06\u8fd4\u56de\u5230\u8868\u8fbe\u5f0f\uff1a<\/p>\n<pre>int y = 4 * 5 \/ 4 + 2; \/\/ x assigned value of 2\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u4ece\u5de6\u5230\u53f3\u8ba1\u7b97\u4e58\u6cd5\u548c\u9664\u6cd5\uff0c\u5e76\u4ee5\u52a0\u6cd5\u7ed3\u675f\u3002\u7136\u540e\u6253\u5370\u7ed3\u679c\uff1a<\/p>\n<pre>x is 2\ny is 7\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u603b\u800c\u8a00\u4e4b\uff0c\u4e00\u5143\u8fd0\u7b97\u7b26\u901a\u8fc7\u542f\u7528\u5feb\u901f\u7684\u5355\u64cd\u4f5c\u6570\u64cd\u4f5c\uff08\u4f8b\u5982\u9012\u589e\u3001\u6c42\u53cd\u6216\u53cd\u8f6c\u503c\uff09\u6765\u7b80\u5316\u548c\u7cbe\u7b80\u4ee3\u7801\u3002\u5b83\u4eec\u5bf9\u4e8e\u9ad8\u6548\u7684\u903b\u8f91\u3001\u7d27\u51d1\u7684\u8868\u8fbe\u5f0f\u548c\u7b80\u6d01\u7684\u6570\u636e\u63a7\u5236\u3001\u589e\u5f3a\u7f16\u7a0b\u7684\u53ef\u8bfb\u6027\u548c\u529f\u80fd\u6027\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528\u4e00\u5143\u8fd0\u7b97\u7b26\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>\u6839\u636e\u5b9a\u4e49\uff0c\u4e00\u5143\u8fd0\u7b97\u7b26\u662f\u53ea\u9700\u8981\u4e00\u4e2a\u64cd\u4f5c\u6570\u6216\u53d8\u91cf\u6765 \u51fd\u6570\u3002\u5b83\u4eec\u7ecf\u5e38\u6267\u884c\u7b80\u5355\u7684\u4efb\u52a1\uff0c\u4f8b\u5982\u589e\u52a0 \u6570\u503c\u53d8\u91cf\u51cf\u4e00\uff0c\u6216\u5bf9\u5e03\u5c14\u503c\u6c42\u8d1f\u3002 \u903b\u8f91\u8865\u7801\u548c\u5426\u5b9a\u8fd0\u7b97\u7b26\u903b\u8f91\u8865\u8fd0\u7b97\u7b26 !\uff0c\u7ffb\u8f6c\u5e03\u5c14\u8868\u8fbe\u5f0f\u7684\u503c\u3002\u4f8b\u5982\uff0c \u5982\u679c\u503c\u4e3a true\uff0c\u5219\u5c06\u5176\u8f6c\u6362\u4e3a false\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002\u4e3a\u4e86\u8bf4\u660e\u8fd9\u4e00\u70b9\uff0c\u8bf7\u6bd4\u8f83 \u4ee5\u4e0b\u8bed\u53e5\u7684\u8f93\u51fa\uff1a boolean x = false; system.out.println(x); \/\/ false x = !x; system.out.println(x); \/\/ true \u767b\u5f55\u540e\u590d\u5236 \u540c\u6837\uff0c\u5426\u5b9a\u8fd0\u7b97\u7b26\uff0c-\uff0c\u53cd\u8f6c\u6570\u503c\u8868\u8fbe\u5f0f\u7684\u7b26\u53f7\uff0c\u5982\u56fe \u5728\u8fd9\u4e9b\u58f0\u660e\u4e2d\uff1a double x = 1.21; system.out.println(x); \/\/ 1.21 x = -x; system.out.println(x); \/\/ -1.21 x = -x; system.out.println(x); \/\/ 1.21 \u767b\u5f55\u540e\u590d\u5236 \u6839\u636e\u63cf\u8ff0\uff0c\u5f88\u660e\u663e\u67d0\u4e9b\u8fd0\u7b97\u7b26\u9700\u8981\u53d8\u91cf \u6216\u4ed6\u4eec\u6b63\u5728\u91c7\u53d6\u884c\u52a8\u7684\u7279\u5b9a\u7c7b\u578b\u7684\u8868\u8fbe\u3002\u4f8b\u5982\uff0c\u60a8\u4e0d\u80fd\u7533\u8bf7 \u5426\u5b9a\u8fd0\u7b97\u7b26 &#8211; \u5e94\u7528\u4e8e\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u4e5f\u4e0d\u80fd\u5e94\u7528\u903b\u8f91\u8865 \u8fd0\u7b97\u7b26 ! \u5230\u6570\u503c\u8868\u8fbe\u5f0f\u3002\u8b66\u60d5\u8003\u8bd5\u4e2d\u8bd5\u56fe\u8fd9\u6837\u505a\u7684\u95ee\u9898\uff0c \u56e0\u4e3a\u5b83\u4eec\u4f1a\u5bfc\u81f4\u4ee3\u7801\u65e0\u6cd5\u7f16\u8bd1\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u4ee3\u7801\u884c\u90fd\u6ca1\u6709 \u5c06\u7f16\u8bd1\uff1a [&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-36491","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36491","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=36491"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36491\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=36491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=36491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=36491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}