{"id":95266,"date":"2026-08-16T16:09:20","date_gmt":"2026-08-16T08:09:20","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/95266.html"},"modified":"2026-08-16T16:09:20","modified_gmt":"2026-08-16T08:09:20","slug":"java-%e8%bf%90%e7%ae%97%e7%ac%a6%ef%bc%9ai-i-%e5%88%b0%e5%ba%95%e7%ad%89%e4%ba%8e%e5%87%a0%ef%bc%9f%e4%b8%80%e6%96%87%e5%bd%bb%e5%ba%95%e6%90%9e%e6%87%82-12-%e7%b1%bb%e8%bf%90%e7%ae%97%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/95266.html","title":{"rendered":"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91"},"content":{"rendered":"<p>\u4ece\u77ed\u8def\u8fd0\u7b97\u7684 NPE \u9677\u9631&#xff0c;\u5230\u4f4d\u8fd0\u7b97\u7684\u6743\u9650\u6821\u9a8c&#xff0c;\u4ece\u5b57\u8282\u7801\u5230\u4f18\u5148\u7ea7&#xff0c;\u8fd9\u7bc7\u5e26\u4f60\u5168\u9762\u901a\u5173<\/p>\n<p>\u6211\u4eec\u4e4b\u524d\u804a\u8fc7&#xff1a;<\/p>\n<ul>\n<li>\u6570\u636e\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u957f\u4ec0\u4e48\u6837\u201d&#xff08;int\u3001String\u3001char&#xff09;<\/li>\n<li>\u53d8\u91cf\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u5b58\u5728\u54ea\u3001\u6d3b\u591a\u4e45\u201d&#xff08;\u5c40\u90e8\u3001\u5b9e\u4f8b\u3001\u9759\u6001&#xff09;<\/li>\n<li>\u4fee\u9970\u7b26&#xff1a;\u5b9a\u4e49\u201c\u8c01\u80fd\u7528\u3001\u6709\u4ec0\u4e48\u7279\u6b8a\u529f\u80fd\u201d&#xff08;public\u3001static\u3001volatile&#xff09;<\/li>\n<\/ul>\n<p>\u4eca\u5929\u6211\u4eec\u6765\u8865\u4e0a Java \u8bed\u6cd5\u4f53\u7cfb\u7684\u6700\u540e\u4e00\u5757\u6838\u5fc3\u62fc\u56fe&#xff1a;\u8fd0\u7b97\u7b26&#xff08;Operators&#xff09;\u3002<\/p>\n<p>\u5982\u679c\u8bf4\u53d8\u91cf\u662f\u201c\u6570\u636e\u5bb9\u5668\u201d&#xff0c;\u90a3\u4e48\u8fd0\u7b97\u7b26\u5c31\u662f\u201c\u6570\u636e\u52a0\u5de5\u5382\u201d\u3002\u7406\u89e3\u4e86\u8fd0\u7b97\u7b26&#xff0c;\u4f60\u5c31\u7406\u89e3\u4e86 Java \u7a0b\u5e8f\u5982\u4f55\u201c\u52a8\u201d\u8d77\u6765\u3002<\/p>\n<h3>\u4e00\u3001Java \u8fd0\u7b97\u7b26\u5168\u666f\u5206\u7c7b&#xff08;12 \u5927\u7c7b&#xff09;<\/h3>\n<table>\n<tr>\u5206\u7c7b\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7&#xff08;\u5927\u81f4&#xff09;<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u7b97\u672f\u8fd0\u7b97\u7b26<\/td>\n<td align=\"left\">&#043; &#8211; * \/ % &#043;&#043; &#8212;<\/td>\n<td align=\"left\">\u9ad8<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u5173\u7cfb\/\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/td>\n<td align=\"left\">&#061;&#061; !&#061; &gt; &lt; &gt;&#061; &lt;&#061;<\/td>\n<td align=\"left\">\u4e2d<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u903b\u8f91\u8fd0\u7b97\u7b26<\/td>\n<td align=\"left\">&amp;&amp; &#096;<\/td>\n<td align=\"left\"><\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u4f4d\u8fd0\u7b97\u7b26<\/td>\n<td align=\"left\">&amp; &#096;<\/td>\n<td align=\"left\"> ^&#096; &#096;~&#096; &#096;&lt;&lt;&#096; &#096;&gt;&gt;&#096; &#096;&gt;&gt;&gt;&#096;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u8d4b\u503c\u8fd0\u7b97\u7b26<\/td>\n<td align=\"left\">&#061; &#043;&#061; -&#061; *&#061; \/&#061; %&#061; &amp;&#061; &#096;<\/td>\n<td align=\"left\">&#061; ^&#061;&#096; &#096;&lt;&lt;&#061;&#096; &#096;&gt;&gt;&#061;&#096; &#096;&gt;&gt;&gt;&#061;&#096;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u6761\u4ef6\u8fd0\u7b97\u7b26&#xff08;\u4e09\u5143&#xff09;<\/td>\n<td align=\"left\">? :<\/td>\n<td align=\"left\">\u4f4e<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">instanceof<\/td>\n<td align=\"left\">instanceof<\/td>\n<td align=\"left\">\u4e2d<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u5176\u4ed6<\/td>\n<td align=\"left\">\u62ec\u53f7 ()\u3001\u6570\u7ec4\u4e0b\u6807 []\u3001\u6210\u5458\u8bbf\u95ee .<\/td>\n<td align=\"left\">\u6700\u9ad8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f525; \u6838\u5fc3\u7ed3\u8bba&#xff1a;\u62ec\u53f7 () \u4f18\u5148\u7ea7\u6700\u9ad8&#xff0c;\u8d4b\u503c &#061; \u4f18\u5148\u7ea7\u6700\u4f4e\u3002\u638c\u63e1\u8fd9\u4e2a&#xff0c;\u5c31\u80fd\u907f\u514d 90% \u7684\u4f18\u5148\u7ea7\u6df7\u4e71\u3002<\/p>\n<h3>\u4e8c\u30019 \u5927\u9ad8\u9891\u9677\u9631\u4e0e\u786c\u6838\u89e3\u6790&#xff08;\u9762\u8bd5\u5fc5\u770b&#xff09;<\/h3>\n<h4>\u9677\u9631 1&#xff1a;i &#061; i&#043;&#043; \u5230\u5e95\u7b49\u4e8e\u51e0&#xff1f;&#xff08;\u7ecf\u5178\u9001\u547d\u9898&#xff09;<\/h4>\n<p><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\ni <span class=\"token operator\">&#061;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>i<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u8f93\u51fa&#xff1a;0<\/span><\/p>\n<p>\u5e95\u5c42\u5b57\u8282\u7801\u89e3\u6790&#xff08;JVM \u89c6\u89d2&#xff09;&#xff1a;<br \/>\n\u7f16\u8bd1\u5668\u5728\u5904\u7406 i&#043;&#043; \u65f6&#xff0c;\u4f1a\u5148\u5c06\u5f53\u524d\u503c 0 \u538b\u5165\u64cd\u4f5c\u6570\u6808&#xff08;\u4e34\u65f6\u5b58\u50a8&#xff09;&#xff0c;\u7136\u540e\u7ed9 i \u52a0 1&#xff08;i \u53d8\u6210 1&#xff09;&#xff0c;\u6700\u540e\u5c06\u6808\u4e2d\u7684\u4e34\u65f6\u503c 0 \u5f39\u51fa\u5e76\u8d4b\u503c\u7ed9 i\u3002<br \/>\n\u6240\u4ee5 i \u7ecf\u5386\u4e86&#xff1a;0 \u2192 \u5b58\u5165\u6808 \u2192 \u81ea\u589e\u6210 1 \u2192 \u6808\u4e2d 0 \u8986\u76d6\u56de i \u2192 \u6700\u7ec8 0\u3002<\/p>\n<table>\n<tr>\u64cd\u4f5c\u64cd\u4f5c\u6570\u6808\u5c40\u90e8\u53d8\u91cf i<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u521d\u59cb<\/td>\n<td align=\"left\">\u7a7a<\/td>\n<td align=\"left\">0<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u52a0\u8f7d i<\/td>\n<td align=\"left\">[0]<\/td>\n<td align=\"left\">0<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">i&#043;&#043;&#xff08;\u81ea\u589e&#xff09;<\/td>\n<td align=\"left\">[0]<\/td>\n<td align=\"left\">1<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">&#061;&#xff08;\u8d4b\u503c&#xff09;<\/td>\n<td align=\"left\">\u5f39\u6808<\/td>\n<td align=\"left\">0&#xff08;\u88ab\u8986\u76d6&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f4a1; &#043;&#043;i \u7684\u533a\u522b&#xff1a;int i&#061;0; int j&#061;&#043;&#043;i; \u2192 \u5148\u81ea\u589e&#xff08;i&#061;1&#xff09;&#xff0c;\u518d\u538b\u6808\u8d4b\u503c&#xff08;j&#061;1&#xff09;\u3002\u8f93\u51fa i&#061;1, j&#061;1\u3002<\/p>\n<h4>\u9677\u9631 2&#xff1a;\u77ed\u8def\u8fd0\u7b97 &amp;&amp; \u548c || \u7684\u201c\u6551\u4eba\u4e00\u547d\u201d<\/h4>\n<p>\u77ed\u8def\u4e0e&#xff08;&amp;&amp;&#xff09;&#xff1a;\u5982\u679c\u5de6\u8fb9\u4e3a false&#xff0c;\u53f3\u8fb9\u6839\u672c\u4e0d\u6267\u884c\u3002<br \/>\n\u77ed\u8def\u6216&#xff08;||&#xff09;&#xff1a;\u5982\u679c\u5de6\u8fb9\u4e3a true&#xff0c;\u53f3\u8fb9\u6839\u672c\u4e0d\u6267\u884c\u3002<\/p>\n<p><span class=\"token class-name\">String<\/span> str <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>str <span class=\"token operator\">!&#061;<\/span> <span class=\"token keyword\">null<\/span> <span class=\"token operator\">&amp;&amp;<\/span> str<span class=\"token punctuation\">.<\/span><span class=\"token function\">length<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>  <span class=\"token comment\">\/\/ \u2705 \u5b89\u5168&#xff0c;\u5de6\u8fb9 false&#xff0c;\u53f3\u8fb9\u4e0d\u6267\u884c&#xff0c;\u4e0d\u4f1a NPE<\/span><br \/>\n    <span class=\"token comment\">\/\/ &#8230;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>str <span class=\"token operator\">!&#061;<\/span> <span class=\"token keyword\">null<\/span> <span class=\"token operator\">&amp;<\/span> str<span class=\"token punctuation\">.<\/span><span class=\"token function\">length<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>   <span class=\"token comment\">\/\/ \u274c \u5371\u9669&#xff01;\u975e\u77ed\u8def &amp;&#xff0c;\u4e24\u8fb9\u90fd\u6267\u884c&#xff0c;\u76f4\u63a5 NPE<\/span><br \/>\n    <span class=\"token comment\">\/\/ &#8230;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8bb0\u5fc6\u53e3\u8bc0&#xff1a;&amp;&amp; \u662f\u201c\u4e00\u5047\u5373\u5047&#xff0c;\u9047\u5047\u5c31\u505c\u201d&#xff1b;|| \u662f\u201c\u4e00\u771f\u5373\u771f&#xff0c;\u9047\u771f\u5c31\u505c\u201d\u3002<\/p>\n<h4>\u9677\u9631 3&#xff1a;\u4f4d\u8fd0\u7b97\u53f3\u79fb &gt;&gt; vs &gt;&gt;&gt;&#xff08;\u7b26\u53f7\u4f4d\u5904\u7406&#xff09;<\/h4>\n<ul>\n<li>&gt;&gt;&#xff1a;\u6709\u7b26\u53f7\u53f3\u79fb&#xff0c;\u5de6\u8fb9\u8865\u7b26\u53f7\u4f4d&#xff08;\u6b63\u6570\u8865 0&#xff0c;\u8d1f\u6570\u8865 1&#xff09;\u3002<\/li>\n<li>&gt;&gt;&gt;&#xff1a;\u65e0\u7b26\u53f7\u53f3\u79fb&#xff0c;\u5de6\u8fb9\u7edf\u4e00\u8865 0&#xff08;\u8d1f\u6570\u7684\u4e8c\u8fdb\u5236\u4f1a\u53d8\u6210\u5f88\u5927\u7684\u6b63\u6570&#xff09;\u3002<\/li>\n<\/ul>\n<p><span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">8<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u4e8c\u8fdb\u5236&#xff1a;11111111 11111111 11111111 11111000<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>a <span class=\"token operator\">&gt;&gt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ -4&#xff08;\u4fdd\u7559\u7b26\u53f7\u4f4d&#xff0c;\u9664\u4ee5 2 \u5411\u4e0b\u53d6\u6574&#xff09;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>a <span class=\"token operator\">&gt;&gt;&gt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ 2147483644&#xff08;\u5de6\u8fb9\u8865 0&#xff0c;\u53d8\u6210\u8d85\u5927\u6b63\u6570&#xff09;<\/span><\/p>\n<p>\u65e5\u5e38\u5f00\u53d1\u4e2d&#xff0c;&gt;&gt;&gt; \u5e38\u89c1\u4e8e\u54c8\u5e0c\u7b97\u6cd5\u3001\u4f4d\u56fe&#xff08;BitMap&#xff09;\u6216\u5e95\u5c42\u7f51\u7edc\u62a5\u6587\u89e3\u6790\u3002<\/p>\n<h4>\u9677\u9631 4&#xff1a;\u590d\u5408\u8d4b\u503c\u8fd0\u7b97\u7b26 &#043;&#061; \u7684\u201c\u9690\u5f62\u5f3a\u8f6c\u201d<\/h4>\n<p><span class=\"token keyword\">byte<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">127<\/span><span class=\"token punctuation\">;<\/span><br \/>\nb <span class=\"token operator\">&#043;&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u2705 \u7f16\u8bd1\u901a\u8fc7&#xff01;b \u53d8\u6210 -128&#xff08;\u53d1\u751f\u6ea2\u51fa&#xff0c;\u4f46\u8bed\u6cd5\u6b63\u786e&#xff09;<\/span><br \/>\nb <span class=\"token operator\">&#061;<\/span> b <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u274c \u7f16\u8bd1\u62a5\u9519&#xff1a;Type mismatch: cannot convert from int to byte<\/span><\/p>\n<p>\u539f\u7406&#xff1a;b &#043;&#061; 1 \u7b49\u4ef7\u4e8e b &#061; (byte)(b &#043; 1)&#xff0c;\u7f16\u8bd1\u5668\u81ea\u52a8\u63d2\u5165\u4e86\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u3002\u800c b &#061; b &#043; 1 \u4e2d&#xff0c;b &#043; 1 \u4f1a\u5148\u7c7b\u578b\u63d0\u5347\u4e3a int&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u8d4b\u503c\u7ed9 byte\u3002<\/p>\n<p>&#x1f6a8; \u8b66\u793a&#xff1a;\u867d\u7136 &#043;&#061; \u7f16\u8bd1\u901a\u8fc7&#xff0c;\u4f46\u6ea2\u51fa\u98ce\u9669\u4f9d\u7136\u5b58\u5728\u3002127 &#043; 1 &#061; -128&#xff0c;\u8fd9\u5728\u4e1a\u52a1\u4e2d\u53ef\u80fd\u662f\u707e\u96be\u6027\u7684\u3002<\/p>\n<h4>\u9677\u9631 5&#xff1a;\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u4e2d\u7684\u201c\u9690\u5f62\u70b8\u5f39\u201d\u2014\u2014\u79fb\u4f4d\u4f4e\u4e8e\u52a0\u51cf<\/h4>\n<p>\u8fd9\u662f 90% \u7684\u5f00\u53d1\u8005\u90fd\u4f1a\u7b54\u9519\u7684\u70b9&#xff1a;<\/p>\n<p><span class=\"token keyword\">int<\/span> result <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token number\">3<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>result<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u8f93\u51fa&#xff1a;32<\/span><\/p>\n<p>\u9519\u8bef\u63a8\u7406&#xff1a;(2 &lt;&lt; 3) &#043; 1 &#061; 16 &#043; 1 &#061; 17 \u274c<br \/>\n\u6b63\u786e\u63a8\u7406&#xff1a;&#043; \u4f18\u5148\u7ea7\u9ad8\u4e8e &lt;&lt;&#xff0c;\u6240\u4ee5 2 &lt;&lt; (3 &#043; 1) &#061; 2 &lt;&lt; 4 &#061; 32 \u2705<\/p>\n<p>&#x1f4cb; \u4f18\u5148\u7ea7\u901f\u8bb0\u53e3\u8bc0&#xff08;\u7531\u9ad8\u5230\u4f4e&#xff09;&#xff1a;<br \/>\n\u62ec\u53f7 &gt; \u5355\u76ee&#xff08;&#043;&#043; &#8212; ! ~&#xff09;&gt; \u7b97\u672f&#xff08;* \/ % &gt; &#043; -&#xff09;&gt; \u79fb\u4f4d&#xff08;&lt;&lt; &gt;&gt; &gt;&gt;&gt;&#xff09;&gt; \u6bd4\u8f83&#xff08;&lt; &gt; &lt;&#061; &gt;&#061; instanceof&#xff09;&gt; \u76f8\u7b49&#xff08;&#061;&#061; !&#061;&#xff09;&gt; \u4f4d\u903b\u8f91&#xff08;&amp; &gt; ^ &gt; |&#xff09;&gt; \u903b\u8f91&#xff08;&amp;&amp; &gt; ||&#xff09;&gt; \u4e09\u5143&#xff08;? :&#xff09;&gt; \u8d4b\u503c&#xff08;&#061;&#xff09;<\/p>\n<h4>\u9677\u9631 6&#xff1a;&#061;&#061; \u4e0e equals() \u7684\u7ecf\u5178\u6df7\u6dc6&#xff08;\u8054\u52a8\u4e4b\u524d\u7684 Integer \u7f13\u5b58\u6c60&#xff09;<\/h4>\n<ul>\n<li>\u57fa\u672c\u7c7b\u578b&#xff08;int\u3001char \u7b49&#xff09;&#xff1a;&#061;&#061; \u6bd4\u8f83\u7684\u662f\u6570\u503c\u672c\u8eab\u3002<\/li>\n<li>\u5f15\u7528\u7c7b\u578b&#xff08;String\u3001Integer \u7b49&#xff09;&#xff1a;&#061;&#061; \u6bd4\u8f83\u7684\u662f\u5185\u5b58\u5730\u5740&#xff08;\u5f15\u7528&#xff09;&#xff0c;equals() \u6bd4\u8f83\u7684\u662f\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<p><span class=\"token class-name\">Integer<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">Integer<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>a <span class=\"token operator\">&#061;&#061;<\/span> b<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ true&#xff08;\u7f13\u5b58\u6c60\u547d\u4e2d&#xff0c;\u540c\u4e00\u5bf9\u8c61&#xff09;<\/span><br \/>\n<span class=\"token class-name\">Integer<\/span> c <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">200<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">Integer<\/span> d <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">200<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#061;&#061;<\/span> d<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ false&#xff08;\u8d85\u51fa -128~127&#xff0c;\u4e0d\u540c\u5bf9\u8c61&#xff09;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">.<\/span><span class=\"token function\">equals<\/span><span class=\"token punctuation\">(<\/span>d<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ true&#xff08;\u5185\u5bb9\u76f8\u540c&#xff09;<\/span><\/p>\n<p>\u94c1\u5f8b&#xff1a;\u5305\u88c5\u7c7b\u6bd4\u8f83\u6570\u503c&#xff0c;\u6c38\u8fdc\u7528 equals()&#xff0c;\u4e0d\u8981\u7528 &#061;&#061;\u3002<\/p>\n<h4>\u9677\u9631 7&#xff1a;instanceof \u4e0e\u6570\u7ec4\/\u63a5\u53e3\u7684\u201c\u5947\u602a\u884c\u4e3a\u201d<\/h4>\n<p><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> arr <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">String<\/span><span class=\"token punctuation\">[<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>arr <span class=\"token keyword\">instanceof<\/span> <span class=\"token class-name\">Object<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/ true&#xff08;\u6570\u7ec4\u662f\u5bf9\u8c61&#xff09;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>arr <span class=\"token keyword\">instanceof<\/span> <span class=\"token class-name\">Object<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ true<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>arr <span class=\"token keyword\">instanceof<\/span> <span class=\"token class-name\">Cloneable<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ true&#xff08;\u6570\u7ec4\u5b9e\u73b0\u4e86 Cloneable&#xff09;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>arr <span class=\"token keyword\">instanceof<\/span> <span class=\"token class-name\">Serializable<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ true&#xff08;\u6570\u7ec4\u5b9e\u73b0\u4e86 Serializable&#xff09;<\/span><\/p>\n<p>instanceof \u53f3\u8fb9\u53ef\u4ee5\u662f\u7c7b\u3001\u63a5\u53e3\u3001\u6570\u7ec4\u7c7b\u578b\u3002\u6570\u7ec4\u5728 JVM \u4e2d\u4e5f\u662f\u5bf9\u8c61&#xff0c;\u4e14\u6709\u5bf9\u5e94\u7684\u7c7b&#xff08;[Ljava.lang.String;&#xff09;\u3002<\/p>\n<h4>\u9677\u9631 8&#xff1a;\u903b\u8f91\u975e ! \u4e0e\u6309\u4f4d\u53d6\u53cd ~ \u7684\u533a\u522b<\/h4>\n<ul>\n<li>!&#xff1a;\u903b\u8f91\u975e&#xff0c;\u53ea\u7528\u4e8e boolean&#xff0c;!true \u2192 false\u3002<\/li>\n<li>~&#xff1a;\u6309\u4f4d\u53d6\u53cd&#xff0c;\u7528\u4e8e\u6574\u6570&#xff0c;\u5c06\u4e8c\u8fdb\u5236\u6bcf\u4e00\u4f4d 0 \u53d8 1\u30011 \u53d8 0&#xff08;\u5305\u62ec\u7b26\u53f7\u4f4d&#xff09;\u3002<\/li>\n<\/ul>\n<p><span class=\"token keyword\">boolean<\/span> flag <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>flag<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ false<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> num <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u4e8c\u8fdb\u5236&#xff1a;0000&#8230;0101<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">~<\/span>num<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ -6&#xff08;\u4e8c\u8fdb\u5236&#xff1a;1111&#8230;1010&#xff0c;\u5373 -6&#xff09;<\/span><\/p>\n<h4>\u9677\u9631 9&#xff1a;\u9664\u96f6\u5f02\u5e38\u2014\u2014\u6574\u6570 vs \u6d6e\u70b9\u6570\u7684\u5dee\u5f02<\/h4>\n<p><span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ \u274c \u8fd0\u884c\u65f6\u629b\u51fa ArithmeticException<\/span><br \/>\n<span class=\"token keyword\">double<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1.0<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u2705 \u8f93\u51fa Infinity&#xff08;IEEE 754 \u89c4\u8303&#xff09;<\/span><br \/>\n<span class=\"token keyword\">double<\/span> c <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0.0<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u2705 \u8f93\u51fa NaN&#xff08;Not a Number&#xff09;<\/span><\/p>\n<p>\u6d6e\u70b9\u6570\u8fd0\u7b97\u9075\u5faa IEEE 754 \u6807\u51c6&#xff0c;\u9047\u5230\u9664\u96f6\u4e0d\u4f1a\u629b\u5f02\u5e38&#xff0c;\u800c\u662f\u8fd4\u56de\u7279\u6b8a\u503c&#xff08;Infinity\u3001-Infinity\u3001NaN&#xff09;\u3002\u5224\u65ad NaN \u8981\u7528 Double.isNaN()&#xff0c;\u4e0d\u8981\u7528 &#061;&#061;\u3002<\/p>\n<h3>\u4e09\u3001\u4f4d\u8fd0\u7b97\u7684\u5b9e\u6218\u573a\u666f&#xff08;\u8ba9\u4ee3\u7801\u66f4\u4f18\u96c5&#xff09;<\/h3>\n<h4>\u573a\u666f 1&#xff1a;\u6743\u9650\u7cfb\u7edf&#xff08;\u4f4d\u63a9\u7801&#xff09;<\/h4>\n<p><span class=\"token comment\">\/\/ \u6743\u9650\u5b9a\u4e49&#xff1a;\u8bfb&#061;1&#xff0c;\u5199&#061;2&#xff0c;\u6267\u884c&#061;4<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">final<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token constant\">READ<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ 001<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">final<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token constant\">WRITE<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ 010<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">final<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token constant\">EXEC<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ 100<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> permission <span class=\"token operator\">&#061;<\/span> <span class=\"token constant\">READ<\/span> <span class=\"token operator\">|<\/span> <span class=\"token constant\">WRITE<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 011&#xff08;\u62e5\u6709\u8bfb\u548c\u5199\u6743\u9650&#xff09;<\/span><br \/>\n<span class=\"token keyword\">boolean<\/span> canRead <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>permission <span class=\"token operator\">&amp;<\/span> <span class=\"token constant\">READ<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ true<\/span><br \/>\n<span class=\"token keyword\">boolean<\/span> canExec <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>permission <span class=\"token operator\">&amp;<\/span> <span class=\"token constant\">EXEC<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ false<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u8ffd\u52a0\u6743\u9650<\/span><br \/>\npermission <span class=\"token operator\">|&#061;<\/span> <span class=\"token constant\">EXEC<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 011 | 100 &#061; 111&#xff08;\u62e5\u6709\u5168\u90e8\u6743\u9650&#xff09;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u79fb\u9664\u6743\u9650<\/span><br \/>\npermission <span class=\"token operator\">&amp;&#061;<\/span> <span class=\"token operator\">~<\/span><span class=\"token constant\">WRITE<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 111 &amp; ~010 &#061; 101&#xff08;\u79fb\u9664\u5199\u6743\u9650&#xff09;<\/span><\/p>\n<h4>\u573a\u666f 2&#xff1a;\u9ad8\u6548\u4e58\u9664 2 \u7684\u5e42&#xff08;\u5e95\u5c42\u4f18\u5316&#xff09;<\/h4>\n<p><span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span><br \/>\na <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u76f8\u5f53\u4e8e a * 2 &#061; 20&#xff08;\u6bd4\u4e58\u6cd5\u5feb&#xff09;<\/span><br \/>\na <span class=\"token operator\">&gt;&gt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u76f8\u5f53\u4e8e a \/ 2 &#061; 5&#xff08;\u6bd4\u9664\u6cd5\u5feb&#xff09;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u4f46\u6ce8\u610f&#xff1a;\u53f3\u79fb\u8d1f\u6570\u65f6\u5411\u4e0b\u53d6\u6574&#xff0c;\u9664\u6cd5\u5411\u96f6\u53d6\u6574<\/span><br \/>\n<span class=\"token keyword\">int<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>b <span class=\"token operator\">&gt;&gt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ -3&#xff08;\u5411\u4e0b\u53d6\u6574&#xff09;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>b <span class=\"token operator\">\/<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ -2&#xff08;\u5411\u96f6\u53d6\u6574&#xff09;<\/span><\/p>\n<h3>\u56db\u3001JVM \u5b57\u8282\u7801\u89c6\u89d2&#xff08;\u8fdb\u9636&#xff09;<\/h3>\n<p>\u8fd0\u7b97\u7b26\u5728\u7f16\u8bd1\u540e&#xff0c;\u4f1a\u53d8\u6210 JVM \u5b57\u8282\u7801\u6307\u4ee4\u3002\u4ee5 int a &#061; 2 &#043; 3; \u4e3a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ Java \u6e90\u7801<\/span><br \/>\n<span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5b57\u8282\u7801&#xff08;javap \u53cd\u7f16\u8bd1&#xff09;<\/span><br \/>\niconst_2   <span class=\"token comment\">\/\/ \u5c06\u5e38\u91cf 2 \u538b\u5165\u64cd\u4f5c\u6570\u6808<\/span><br \/>\niconst_3   <span class=\"token comment\">\/\/ \u5c06\u5e38\u91cf 3 \u538b\u5165\u64cd\u4f5c\u6570\u6808<\/span><br \/>\niadd       <span class=\"token comment\">\/\/ \u5f39\u51fa\u6808\u9876\u4e24\u4e2a int&#xff0c;\u76f8\u52a0\u540e\u5c06\u7ed3\u679c\u538b\u56de\u6808\u9876<\/span><br \/>\nistore_1   <span class=\"token comment\">\/\/ \u5c06\u6808\u9876\u503c\u5f39\u51fa&#xff0c;\u5b58\u50a8\u5230\u5c40\u90e8\u53d8\u91cf\u8868\u7684\u69fd\u4f4d 1&#xff08;\u5373\u53d8\u91cf a&#xff09;<\/span><\/p>\n<table>\n<tr>\u8fd0\u7b97\u7b26\u5bf9\u5e94\u5b57\u8282\u7801\u6307\u4ee4&#xff08;\u90e8\u5206&#xff09;<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">&#043; &#8211; * \/ %&#xff08;int&#xff09;<\/td>\n<td align=\"left\">iadd\u3001isub\u3001imul\u3001idiv\u3001irem<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">&#043;&#043; &#8211;&#xff08;int&#xff09;<\/td>\n<td align=\"left\">iinc&#xff08;\u76f4\u63a5\u5728\u5c40\u90e8\u53d8\u91cf\u8868\u81ea\u589e&#xff0c;\u65e0\u9700\u538b\u6808&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">&#061;&#061;&#xff08;int&#xff09;<\/td>\n<td align=\"left\">if_icmpeq\u3001if_icmpne<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">&amp;&amp;&#xff08;boolean&#xff09;<\/td>\n<td align=\"left\">ifeq&#xff08;\u6761\u4ef6\u8df3\u8f6c&#xff0c;\u5b9e\u73b0\u77ed\u8def&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">&lt;&lt; &gt;&gt; &gt;&gt;&gt;<\/td>\n<td align=\"left\">ishl\u3001ishr\u3001iushr<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5173\u952e&#xff1a;iinc \u6307\u4ee4\u662f\u76f4\u63a5\u5728\u5c40\u90e8\u53d8\u91cf\u8868\u4e0a\u64cd\u4f5c\u7684&#xff0c;\u4e0d\u7ecf\u8fc7\u64cd\u4f5c\u6570\u6808&#xff0c;\u6240\u4ee5 i&#043;&#043; \u7684\u6548\u7387\u5176\u5b9e\u975e\u5e38\u9ad8\u3002\u4f46 i &#061; i&#043;&#043; \u591a\u4e86\u4e00\u6b65 istore \u8986\u76d6&#xff0c;\u5bfc\u81f4\u4e86\u4e0a\u9762\u7684\u9677\u9631\u3002<\/p>\n<h3>\u4e94\u3001\u5b9e\u6218\u907f\u5751\u603b\u7ed3<\/h3>\n<table>\n<tr>\u573a\u666f\u63a8\u8350\u505a\u6cd5<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u5224\u7a7a\u540e\u518d\u8c03\u7528\u65b9\u6cd5<\/td>\n<td align=\"left\">\u7528 &amp;&amp; \u77ed\u8def\u8fd0\u7b97&#xff0c;\u4e0d\u8981\u7528 &amp;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u5305\u88c5\u7c7b\/\u5bf9\u8c61\u6bd4\u8f83<\/td>\n<td align=\"left\">\u6c38\u8fdc\u7528 equals()&#xff0c;&#061;&#061; \u53ea\u7528\u6765\u6bd4\u8f83\u57fa\u672c\u7c7b\u578b\u6216\u5224\u65ad\u662f\u5426\u4e3a null<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u6d6e\u70b9\u6570\u5224\u65ad\u662f\u5426\u4e3a 0<\/td>\n<td align=\"left\">\u7528 Math.abs(a) &lt; 1e-6&#xff0c;\u4e0d\u8981\u7528 a &#061;&#061; 0<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u6743\u9650\u63a7\u5236\/\u72b6\u6001\u4f4d<\/td>\n<td align=\"left\">\u7528\u4f4d\u8fd0\u7b97\u7b26 &amp;\u3001&#096;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u590d\u6742\u8868\u8fbe\u5f0f<\/td>\n<td align=\"left\">\u52a0\u62ec\u53f7&#xff01; \u4e0d\u8981\u4f9d\u8d56\u4f18\u5148\u7ea7\u8bb0\u5fc6&#xff0c;\u8ba9\u4ee3\u7801\u4e00\u773c\u5c31\u80fd\u770b\u61c2<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u9664\u4ee5 2 \u7684\u5e42\u6b21\u4f18\u5316<\/td>\n<td align=\"left\">\u7528 &gt;&gt; \u6216 &lt;&lt; \u4ee3\u66ff * \/&#xff08;\u4f46\u8981\u6ce8\u610f\u8d1f\u6570\u53d6\u6574\u7684\u5dee\u5f02&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u516d\u3001\u601d\u8003\u9898&#xff08;\u68c0\u9a8c\u662f\u5426\u771f\u7684\u61c2\u4e86&#xff09;<\/h3>\n<p>\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801&#xff0c;\u6bcf\u4e00\u884c\u7684\u8f93\u51fa\u5206\u522b\u662f\u4ec0\u4e48&#xff1f;\u4e3a\u4ec0\u4e48&#xff1f;<\/p>\n<p><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>           <span class=\"token comment\">\/\/ 1<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#043;&#043;<\/span>i<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>           <span class=\"token comment\">\/\/ 2<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>i <span class=\"token operator\">&#061;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>       <span class=\"token comment\">\/\/ 3<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> j <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span> <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token operator\">&#043;&#043;<\/span>j<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/\/ 4<\/span><\/p>\n<p><span class=\"token keyword\">boolean<\/span> flag <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span>flag <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ 5&#xff08;\u6ce8\u610f&#xff01;\u8fd9\u91cc\u4e0d\u662f\u6bd4\u8f83&#xff09;<\/span><\/p>\n<p>\u7b54\u6848&#xff08;\u9009\u4e2d\u4e0b\u65b9\u7a7a\u767d\u533a\u57df\u67e5\u770b&#xff09;&#xff1a;<\/p>\n<li>0&#xff08;\u5148\u6253\u5370\u540e\u81ea\u589e&#xff09;<\/li>\n<li>2&#xff08;\u7b2c\u4e00\u6b21\u8f93\u51fa\u540e i&#061;1&#xff0c;&#043;&#043;i \u5148\u81ea\u589e\u6210 2 \u518d\u6253\u5370&#xff09;<\/li>\n<li>2&#xff08;\u5148\u81ea\u589e\u518d\u8986\u76d6&#xff0c;\u8fc7\u7a0b\u548c\u9677\u9631 1 \u4e00\u6837&#xff0c;i \u5148\u53d8 3 \u518d\u88ab\u6808\u4e2d 2 \u8986\u76d6&#xff09;<\/li>\n<li>2 &lt;&lt; 6 &#061; 128&#xff08;&#043;&#043;j \u5148\u7b97&#xff0c;j&#061;6&#xff0c;\u7136\u540e 2 &lt;&lt; 6&#xff09;<\/li>\n<li>true&#xff08;\u6ce8\u610f\u662f\u8d4b\u503c &#061;&#xff0c;\u4e0d\u662f\u6bd4\u8f83 &#061;&#061;&#xff0c;flag \u88ab\u8d4b\u503c\u4e3a true \u5e76\u6253\u5370\u51fa\u6765&#xff09;<\/li>\n<p>&#x1f4ac; \u4e92\u52a8\u8bdd\u9898&#xff1a;\u4f60\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u6709\u6ca1\u6709\u56e0\u4e3a &#043;&#043; \u7684\u524d\u7f6e\u540e\u7f6e\u3001\u6216\u8005\u77ed\u8def\u4e0e\u975e\u77ed\u8def\u8fd0\u7b97\u7b26\u641e\u6df7&#xff0c;\u5bfc\u81f4\u8fc7\u7ebf\u4e0a Bug&#xff1f;\u6b22\u8fce\u8bc4\u8bba\u533a\u5206\u4eab\u4f60\u7684\u8840\u6cea\u53f2&#xff01;&#x1f680;<\/p>\n<hr \/>\n<p>\u5982\u679c\u89c9\u5f97\u6709\u6536\u83b7&#xff0c;\u522b\u5fd8\u4e86\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u8f6c\u53d1&#xff0c;\u8ba9\u66f4\u591a Javaer \u5f7b\u5e95\u641e\u61c2\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91&#xff01;\u6211\u4eec\u4e0b\u7bc7\u89c1&#xff01;&#x1f44b;<\/p>\n<p>\u53d1\u5e03\u65e5\u671f&#xff1a;2026-08-16<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u77ed\u8def\u8fd0\u7b97\u7684 NPE \u9677\u9631&#xff0c;\u5230\u4f4d\u8fd0\u7b97\u7684\u6743\u9650\u6821\u9a8c&#xff0c;\u4ece\u5b57\u8282\u7801\u5230\u4f18\u5148\u7ea7&#xff0c;\u8fd9\u7bc7\u5e26\u4f60\u5168\u9762\u901a\u5173\u6211\u4eec\u4e4b\u524d\u804a\u8fc7&#xff1a;<br \/>\n\u6570\u636e\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u957f\u4ec0\u4e48\u6837\u201d&#xff08;int\u3001String\u3001char&#xff09;\u53d8\u91cf\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u5b58\u5728\u54ea\u3001\u6d3b\u591a\u4e45\u201d&#xff08;\u5c40\u90e8\u3001\u5b9e\u4f8b\u3001\u9759\u6001&#xff09;\u4fee\u9970\u7b26&#xff1a;\u5b9a\u4e49\u201c\u8c01\u80fd\u7528\u3001\u6709\u4ec0\u4e48\u7279\u6b8a\u529f\u80fd\u201d&#xff08;public\u3001static\u3001volatile&amp;#xff09<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10336,7813,99,190],"topic":[],"class_list":["post-95266","post","type-post","status-publish","format-standard","hentry","category-server","tag-10336","tag-7813","tag-java","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/95266.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4ece\u77ed\u8def\u8fd0\u7b97\u7684 NPE \u9677\u9631&#xff0c;\u5230\u4f4d\u8fd0\u7b97\u7684\u6743\u9650\u6821\u9a8c&#xff0c;\u4ece\u5b57\u8282\u7801\u5230\u4f18\u5148\u7ea7&#xff0c;\u8fd9\u7bc7\u5e26\u4f60\u5168\u9762\u901a\u5173\u6211\u4eec\u4e4b\u524d\u804a\u8fc7&#xff1a; \u6570\u636e\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u957f\u4ec0\u4e48\u6837\u201d&#xff08;int\u3001String\u3001char&#xff09;\u53d8\u91cf\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u5b58\u5728\u54ea\u3001\u6d3b\u591a\u4e45\u201d&#xff08;\u5c40\u90e8\u3001\u5b9e\u4f8b\u3001\u9759\u6001&#xff09;\u4fee\u9970\u7b26&#xff1a;\u5b9a\u4e49\u201c\u8c01\u80fd\u7528\u3001\u6709\u4ec0\u4e48\u7279\u6b8a\u529f\u80fd\u201d&#xff08;public\u3001static\u3001volatile&amp;#xff09\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/95266.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-16T08:09:20+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/95266.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/95266.html\",\"name\":\"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-16T08:09:20+00:00\",\"dateModified\":\"2026-08-16T08:09:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/95266.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/95266.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/95266.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/95266.html","og_locale":"zh_CN","og_type":"article","og_title":"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4ece\u77ed\u8def\u8fd0\u7b97\u7684 NPE \u9677\u9631&#xff0c;\u5230\u4f4d\u8fd0\u7b97\u7684\u6743\u9650\u6821\u9a8c&#xff0c;\u4ece\u5b57\u8282\u7801\u5230\u4f18\u5148\u7ea7&#xff0c;\u8fd9\u7bc7\u5e26\u4f60\u5168\u9762\u901a\u5173\u6211\u4eec\u4e4b\u524d\u804a\u8fc7&#xff1a; \u6570\u636e\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u957f\u4ec0\u4e48\u6837\u201d&#xff08;int\u3001String\u3001char&#xff09;\u53d8\u91cf\u7c7b\u578b&#xff1a;\u5b9a\u4e49\u201c\u503c\u5b58\u5728\u54ea\u3001\u6d3b\u591a\u4e45\u201d&#xff08;\u5c40\u90e8\u3001\u5b9e\u4f8b\u3001\u9759\u6001&#xff09;\u4fee\u9970\u7b26&#xff1a;\u5b9a\u4e49\u201c\u8c01\u80fd\u7528\u3001\u6709\u4ec0\u4e48\u7279\u6b8a\u529f\u80fd\u201d&#xff08;public\u3001static\u3001volatile&amp;#xff09","og_url":"https:\/\/www.wsisp.com\/helps\/95266.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-16T08:09:20+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/95266.html","url":"https:\/\/www.wsisp.com\/helps\/95266.html","name":"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-16T08:09:20+00:00","dateModified":"2026-08-16T08:09:20+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/95266.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/95266.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/95266.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Java \u8fd0\u7b97\u7b26\uff1ai = i++ \u5230\u5e95\u7b49\u4e8e\u51e0\uff1f\u4e00\u6587\u5f7b\u5e95\u641e\u61c2 12 \u7c7b\u8fd0\u7b97\u7b26\u7684\u5e95\u5c42\u903b\u8f91"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/95266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=95266"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/95266\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=95266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=95266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=95266"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=95266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}