{"id":115,"date":"2017-02-12T15:08:00","date_gmt":"2017-02-12T07:08:00","guid":{"rendered":"https:\/\/cn1.club\/?p=115"},"modified":"2025-03-13T20:12:33","modified_gmt":"2025-03-13T12:12:33","slug":"day3-%e7%ac%94%e8%ae%b0-%e4%bd%8d%e8%bf%90%e7%ae%97%e7%ac%a6%e7%9a%84%e5%9f%ba%e6%9c%ac%e7%94%a8%e6%b3%95%e4%b8%8e%e7%89%b9%e7%82%b9","status":"publish","type":"post","link":"https:\/\/cn1.club\/?p=115","title":{"rendered":"Day3 \u7b14\u8bb0 \u4f4d\u8fd0\u7b97\u7b26\u7684\u57fa\u672c\u7528\u6cd5\u4e0e\u7279\u70b9"},"content":{"rendered":"\n<p><strong>\u7528\u6cd51:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >class Demo3_Operator {\n public static void main(String&#091;] args) {\n  \/*\n  &amp;,|,^,~ \u7684\u7528\u6cd5\n  &amp;:\u67090\u52190\n  |:\u67091\u52191\n  ^:\u76f8\u540c\u52190\uff0c\u4e0d\u540c\u52191\n  ~:\u6309\u4f4d\u53d6\u53cd\n  *\/\n  System.out.println(6 &amp; 3);   \/\/2\n  System.out.println(6 | 3);   \/\/7\n  System.out.println(6 ^ 3);   \/\/5\n  System.out.println(~6);    \/\/-7\n\n }\n}\n\/*\n     110\n&amp;   011\n-----------\n     010\n\n     110\n|    011\n-----------\n     111\n\n     110\n^   011\n------------\n     101\n\n     00000000 00000000 00000000 00000110  6\u7684\u539f\u7801\u53cd\u7801\u8865\u7801\u90fd\u662f\u672c\u8eab\n     11111111 11111111 11111111 11111001  \u5bf96 \u53d6\u53cd\n-    00000000 00000000 00000000 00000001\n----------------------------------------------------------------\n     11111111 11111111 11111111 11111000  \u53cd\u7801\n     10000000 00000000 00000000 00000111  \u539f\u7801(-7)\n\n \n\n \n\n*\/<\/code><\/pre>\n\n\n\n<p><strong>\u7528\u6cd52:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >class Demo5_Operator {\n public static void main(String&#091;] args) {\n \/*\n &lt;&lt;:\u5de6\u79fb  \u5de6\u8fb9\u6700\u9ad8\u4f4d\u4e22\u5f03 , \u53f3\u8fb9\u8865\u9f50 0\n &gt;&gt;:\u53f3\u79fb  \u6700\u9ad8\u4f4d\u662f0,\u5de6\u8fb9\u8865\u9f500;\u6700\u9ad8\u4f4d\u662f1,\u5de6\u8fb9\u8865\u9f501\n &gt;&gt;&gt;:\u65e0\u7b26\u53f7\u53f3\u79fb \u65e0\u8bba\u6700\u9ad8\u4f4d\u662f0 \u8fd8\u662f 1,\u5de6\u8fb9\u8865\u9f50 0\n -\u9762\u8bd5\u9898:\u6700\u6709\u6548\u7387\u7684\u7b97\u51fa 2 * 8 \u7684\u7ed3\u679c.\n *\/\n\n  \/\/\u5de6\u79fb,\u5411\u5de6\u79fb\u52a8\u51e0\u4f4d\u5c31\u662f\u4e58\u4ee52\u7684\u51e0\u6b21\u5e42\n  System.out.println(12 &lt;&lt; 1);  \/\/24\n  System.out.println(12 &lt;&lt; 2);  \/\/48\n  \/*\n  00000000 00000000 00000000 00001100   12\u7684\u8865\u7801\n  (0)0000000 00000000 00000000 000011000   24\u7684\u8865\u7801\n (00)000000 00000000 00000000 0000110000   48\u7684\u8865\u7801\n  *\/\n\n\n  \/\/\u53f3\u79fb,\u5411\u53f3\u79fb\u52a8\u51e0\u4f4d\u5c31\u662f\u9664\u4ee52\u7684\u51e0\u6b21\u5e42\n  System.out.println(12 &gt;&gt; 1);    \/\/6\n  System.out.println(12 &gt;&gt; 2);    \/\/3\n\n  \/*\n  00000000 00000000 00000000 00001100   12\u7684\u8865\u7801\n  000000000 00000000 00000000 0000110(0)  6\n  0000000000 00000000 00000000 000011(00)  3\n  *\/\n\n  \/\/\u6700\u6709\u6548\u7387\u7684\u7b97\u51fa 2 * 8 \u7684\u7ed3\u679c\n  System.out.println( 2 &lt;&lt; 3 );\n }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u4f4d\u5f02\u6216\u8fd0\u7b97\u7b26\u7684\u7279\u70b9:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >class Demo4_Operator {\n\tpublic static void main(String&#091;] args) {\n\t\t\/*\n\t\t-\u4f4d\u5f02\u6216\u8fd0\u7b97\u7b26\u7684\u7279\u70b9\n\n\t\t ^\u7684\u7279\u70b9:\u4e00\u4e2a\u6570\u636e\u5bf9\u4e24\u4e00\u4e2a\u6570\u636e\u4f4d\u5f02\u6216\u4e24\u6b21,\u8be5\u6570\u672c\u8eab\u4e0d\u53d8.\n\t\t*\/\n\t\tSystem.out.println(5 ^ 10 ^ 10);\n\t\tSystem.out.println(5 ^ 10 ^ 5);\n\t\t\/*\n\t\t\u9762\u8bd5\u9898:\u8bf7\u81ea\u5df1\u5b9e\u73b0\u4e24\u4e2a\u6574\u6570\u53d8\u91cf\u7684\u4ea4\u6362(\u4e0d\u9700\u8981\u5b9a\u4e49\u7b2c\u4e09\u65b9\u53d8\u91cf)\n\t\t\n\t\t*\/\n\t\tint x = 10;\n\t\tint y = 5;\n\n\t\t\/\/\u9700\u8981\u7b2c\u4e09\u65b9\u53d8\u91cf,\u5f00\u53d1\u63a8\u8350\u4f7f\u7528\u8fd9\u79cd\n\t\t\/\/int temp;\n\t\t\/\/temp = x;\n\t\t\/\/x = y;\n\t\t\/\/y = temp;\n\n\t\t\/\/\u4e0d\u9700\u8981\u5b9a\u4e49\u7b2c\u4e09\u65b9\u53d8\u91cf,\u6709\u5f0a\u7aef,\u6709\u53ef\u80fd\u4f1a\u8d85\u51faint\u7684\u53d6\u503c\u8303\u56f4\n\t\t\/*\n\t\tx = x + y;\t\t\t\t\/\/10 + 5 = 15\n\t\ty = x - y;\t\t\t\t\/\/15 - 5 = 10\n\t\tx = x - y;\t\t\t\t\/\/15 - 10 = 5\n\t\t*\/\n\t\t\n\t\t\/\/\u4e0d\u9700\u8981\u5b9a\u4e49\u7b2c\u4e09\u65b9\u53d8\u91cf\n\t\tx = x ^ y;\t\t\t\t\t\/\/10 ^ 5\n\t\ty = x ^ y;\t\t\t\t\t\/\/10 ^ 5 ^ 5     y = 10\n\t\tx = x ^ y;\t\t\t\t\t\/\/10 ^ 5 ^ 10    x = 5\n\n\n\t\tSystem.out.println(&quot;x = &quot; +  x + &quot;,y= &quot; + y );\n\n\n\t}\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7528\u6cd51: \u7528\u6cd52: \u4f4d\u5f02\u6216\u8fd0\u7b97\u7b26\u7684\u7279\u70b9:<\/p>\n","protected":false},"author":1,"featured_media":196,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-xuexi"],"_links":{"self":[{"href":"https:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":0,"href":"https:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/media\/196"}],"wp:attachment":[{"href":"https:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}