{"id":38014,"date":"2024-11-26T14:34:48","date_gmt":"2024-11-26T06:34:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/38014\/"},"modified":"2024-11-26T14:34:48","modified_gmt":"2024-11-26T06:34:48","slug":"java%e4%b8%ad%e6%80%8e%e4%b9%88%e5%ae%9a%e4%b9%89%e9%80%bb%e8%be%91%e7%b1%bb%e5%9e%8b%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/38014\/","title":{"rendered":"java\u4e2d\u600e\u4e48\u5b9a\u4e49\u903b\u8f91\u7c7b\u578b\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\u7528\u4e8e\u5b58\u50a8\u5e03\u5c14\u503c\uff0c\u5b9a\u4e49\u65b9\u6cd5\u662f boolean[] booleanarray = new boolean[size]\u3002\u521d\u59cb\u5316\u65f6\u53ef\u660e\u786e\u8d4b\u503c\u6216\u4f7f\u7528\u9ed8\u8ba4\u503c\uff08false\uff09\uff0c\u8bbf\u95ee\u5143\u7d20\u7528\u65b9\u62ec\u53f7\u8fd0\u7b97\u7b26 []\uff0c\u904d\u5386\u7528 for-each \u5faa\u73af\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111315130874043.jpg\" class=\"aligncenter\" title=\"java\u4e2d\u600e\u4e48\u5b9a\u4e49\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u4e2d\u600e\u4e48\u5b9a\u4e49\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>Java\u4e2d\u5b9a\u4e49\u903b\u8f91\u7c7b\u578b\u6570\u7ec4<\/strong><\/p>\n<p>\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\u7528\u4e8e\u5b58\u50a8\u771f\u5047\u503c\uff08\u5e03\u5c14\u503c\uff09\uff0c\u662f\u6700\u7b80\u5355\u7684\u6570\u7ec4\u7c7b\u578b\u4e4b\u4e00\u3002<\/p>\n<p><strong>\u5b9a\u4e49\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>boolean[] booleanArray = new boolean[size];<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5176\u4e2d\uff0cbooleanArray\u662f\u6570\u7ec4\u540d\u79f0\uff0csize\u662f\u6570\u7ec4\u5143\u7d20\u7684\u4e2a\u6570\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b 5 \u4e2a\u5143\u7d20\u7684\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\uff1a<\/p>\n<pre>boolean[] truthTable = new boolean[5];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u521d\u59cb\u5316\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u660e\u786e\u5730\u4e3a\u6570\u7ec4\u5143\u7d20\u8d4b\u503c\uff0c\u6216\u4f7f\u7528\u9ed8\u8ba4\u503c\uff08false\uff09\uff1a<\/p>\n<pre>\/\/ \u660e\u786e\u8d4b\u503c\ntruthTable[0] = true;\ntruthTable[1] = false;\ntruthTable[2] = true;\ntruthTable[3] = true;\ntruthTable[4] = false;\n\n\/\/ \u9ed8\u8ba4\u503c\nboolean[] defaultArray = new boolean[5]; \/\/ \u6240\u6709\u5143\u7d20\u90fd\u4e3a false<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8bbf\u95ee\u5143\u7d20\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528\u65b9\u62ec\u53f7\u8fd0\u7b97\u7b26 [] \u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff1a<\/p>\n<pre>if (truthTable[2]) {\n  \/\/ \u6267\u884c\u771f\u503c\u64cd\u4f5c\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u904d\u5386\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 for-each \u5faa\u73af\u904d\u5386\u6574\u4e2a\u6570\u7ec4\uff1a<\/p>\n<pre>for (boolean element : truthTable) {\n  System.out.println(element);\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u4e2d\u600e\u4e48\u5b9a\u4e49\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\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>\u5728 java \u4e2d\uff0c\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\u7528\u4e8e\u5b58\u50a8\u5e03\u5c14\u503c\uff0c\u5b9a\u4e49\u65b9\u6cd5\u662f boolean[] booleanarray = new boolean[size]\u3002\u521d\u59cb\u5316\u65f6\u53ef\u660e\u786e\u8d4b\u503c\u6216\u4f7f\u7528\u9ed8\u8ba4\u503c\uff08false\uff09\uff0c\u8bbf\u95ee\u5143\u7d20\u7528\u65b9\u62ec\u53f7\u8fd0\u7b97\u7b26 []\uff0c\u904d\u5386\u7528 for-each \u5faa\u73af\u3002 Java\u4e2d\u5b9a\u4e49\u903b\u8f91\u7c7b\u578b\u6570\u7ec4 \u903b\u8f91\u7c7b\u578b\u6570\u7ec4\u7528\u4e8e\u5b58\u50a8\u771f\u5047\u503c\uff08\u5e03\u5c14\u503c\uff09\uff0c\u662f\u6700\u7b80\u5355\u7684\u6570\u7ec4\u7c7b\u578b\u4e4b\u4e00\u3002 \u5b9a\u4e49\u65b9\u6cd5\uff1a boolean[] booleanArray = new boolean[size]; \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5176\u4e2d\uff0cbooleanArray\u662f\u6570\u7ec4\u540d\u79f0\uff0csize\u662f\u6570\u7ec4\u5143\u7d20\u7684\u4e2a\u6570\u3002 \u793a\u4f8b\uff1a \u5b9a\u4e49\u4e00\u4e2a\u5305\u542b 5 \u4e2a\u5143\u7d20\u7684\u903b\u8f91\u7c7b\u578b\u6570\u7ec4\uff1a boolean[] truthTable = new boolean[5]; \u767b\u5f55\u540e\u590d\u5236 \u521d\u59cb\u5316\uff1a \u53ef\u4ee5\u660e\u786e\u5730\u4e3a\u6570\u7ec4\u5143\u7d20\u8d4b\u503c\uff0c\u6216\u4f7f\u7528\u9ed8\u8ba4\u503c\uff08false\uff09\uff1a \/\/ \u660e\u786e\u8d4b\u503c truthTable[0] = true; truthTable[1] = false; truthTable[2] = true; truthTable[3] = true; truthTable[4] = false; \/\/ \u9ed8\u8ba4\u503c boolean[] defaultArray = [&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-38014","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38014","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=38014"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38014\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=38014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=38014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=38014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}