{"id":58,"date":"2015-12-03T19:35:26","date_gmt":"2015-12-03T11:35:26","guid":{"rendered":"http:\/\/www.prayerlaputa.com\/?p=58"},"modified":"2015-12-03T19:35:26","modified_gmt":"2015-12-03T11:35:26","slug":"java%e4%b8%adii%e9%97%ae%e9%a2%98%e5%88%86%e6%9e%90%e3%80%90%e8%bd%ac%e8%bd%bd%e3%80%91","status":"publish","type":"post","link":"http:\/\/prayerlaputa.com\/?p=58","title":{"rendered":"java\u4e2di=i++\u95ee\u9898\u5206\u6790\u3010\u8f6c\u8f7d\u3011"},"content":{"rendered":"<p>\u6709\u8fd9\u4e48\u4e00\u9053java\u9898\u76ee\uff0c\u8ba9\u4eba\u89c9\u5f97\u5f88\u8d39\u89e3\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">int i = 0;\ni = i++;\nSystem.out.println(i);\n<\/pre>\n<p>i\u6253\u5370\u51fa\u7684\u7ed3\u679c\u662f0\uff01\uff01\u76f8\u540c\u7684\u8868\u8fbe\u5f0f\u5728C\u4e2d\u5219\u662f\u6211\u4eec\u6240\u60f3\u8c61\u76841\uff01\uff01\u8fd9\u4e2a\u95ee\u9898\u4ece\u5b57\u8282\u7801\u89d2\u5ea6\u8003\u8651\u5c31\u6bd4\u8f83\u5bb9\u6613\u7406\u89e3\u4e86\u3002\u4e0b\u9762\u7ed9\u51fa\u6211\u641c\u5230\u7684\u4e00\u4e2a\u5206\u6790\u7684\u6bd4\u8f83\u6e05\u695a\u7684\u5e16\u5b50\uff0c\u7ed9\u5927\u5bb6\u770b\u770b\uff1a<br \/>\n\u539f\u5e16\u5730\u5740\uff1a<a href=\"http:\/\/piaoboqiu.blog.163.com\/blog\/static\/123127827200910192122472\/\">http:\/\/piaoboqiu.blog.163.com\/blog\/static\/123127827200910192122472\/<\/a><br \/>\n\u5177\u4f53\u6d4b\u8bd5\u4e00\u4e0b\u4ee5\u8bf4\u660e\u95ee\u9898\uff1a<!--more--><br \/>\n\u4ee3\u78011\uff1a<span id=\"more-555\"><\/span><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">public class Test{\n public static void main(String[] args){\n int i=0;\n i=i++;\n System.out.println(i);\n }\n}\n<\/pre>\n<p>\u7ed3\u679ci\u4f9d\u7136\u662f0.\u5206\u6790\u5176\u53cd\u7f16\u8bd1\u540e\u7684\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">public static void main(java.lang.String[]);\n Code:\n 0: iconst_0 \/\/0\u653e\u5230\u6808\u9876\n 1: istore_1 \/\/\u628a\u6808\u9876\u7684\u503c\u4fdd\u5b58\u5230\u5c40\u90e8\u53d8\u91cf1\uff0c\u4e5f\u5c31\u662fi\u4e2d\n 2: iload_1 \/\/\u628ai\u7684\u503c\u653e\u5230\u6808\u9876\uff0c\u4e5f\u5c31\u662f\u8bf4\u6b64\u65f6\u6808\u9876\u7684\u503c\u662f0\n 3: iinc 1, 1 \/\/\u6ce8\u610f\u8fd9\u4e2a\u6307\u4ee4\uff0c\u628a\u5c40\u90e8\u53d8\u91cf1\uff0c\u4e5f\u5c31\u662fi\uff0c\u589e\u52a01\uff0c\u8fd9\u4e2a\u6307\u4ee4\u4e0d\u4f1a\u5bfc\u81f4\u6808\u7684\u53d8\u5316\uff0c\u4e5f\u5c31\u662f\u8bf4\u5c40\u90e8\u53d8\u91cf1\uff0c\u5373i\u6b64\u65f6\u4e3a1\u4e86\u3002\n 6: istore_1 \/\/\u628a\u6808\u9876\u7684\u503c\uff080\uff09\u4fdd\u5b58\u5230\u5c40\u90e8\u53d8\u91cf1\uff0c\u4e5f\u5c31\u662f\u8ba9i\u4e3a0\u4e86\uff0c\u6240\u4ee5\u6700\u540ei\u4e3a0\n 7: getstatic #2; \/\/Field java\/lang\/System.out:Ljava\/io\/PrintStream;\n 10: iload_1\n 11: invokevirtual #3; \/\/Method java\/io\/PrintStream.println:(I)V\n 14: return\n<\/pre>\n<p>\u503c\u5f97\u6ce8\u610f\u5230\u662fi\u88ab\u4fee\u6539\u4e86\u4e24\u6b21\uff0c\u7b2c\u4e00\u6b21\u662fi++\uff1bi\u53d8\u4e3a1\uff0c\u6700\u540e\u4e00\u6b21\u662fi=0\uff1b\u6240\u4ee5\u7ed3\u679ci\u662f0<br \/>\n\u4ee3\u78012\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">public class Test2{\n public static void main(String[] args){\n int i=0;\n int j=0;\n j=i++;\n System.out.println(i);\n System.out.println(j);\n }\n}\n<\/pre>\n<p>\u8fd9\u4e2a\u7ed3\u679c\u80af\u5b9a\u90fd\u77e5\u9053\uff0ci\u662f1\uff0cj\u662f0.\u540c\u6837\u770b\u53cd\u7f16\u8bd1\u4e4b\u540e\u7684\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">public static void main(java.lang.String[]);\n Code:\n 0: iconst_0\n 1: istore_1 \/\/i=0\n 2: iconst_0\n 3: istore_2 \/\/j=0\n 4: iload_1 \/\/\u628ai\u7684\u503c\u653e\u5230\u6808\u9876\uff0c\u4e5f\u5c31\u662f\u8bf4\u6b64\u65f6\u6808\u9876\u7684\u503c\u662f0\n 5: iinc 1, 1 \/\/\u5c40\u90e8\u53d8\u91cf1\u52a01\uff0c\u4e5f\u5c31\u662f\u8ba9i++\u4e86\uff0c\u6b64\u65f6i\u5df2\u7ecf\u662f1\u4e86\uff0c\u4e0a\u9762\u8bf4\u8fc7\uff0c\u6b64\u6307\u4ee4\u4e0d\u4f1a\u5bfc\u81f4\u6808\u53d8\u5316\n 8: istore_2 \/\/\u628a\u6808\u9876\u7684\u503c\uff08\u6ce8\u610f\u662f0\uff09\u5b58\u5165\u5c40\u90e8\u53d8\u91cf2\uff0c\u4e5f\u5c31\u662fj\u4e2d\uff0c\u6240\u4ee5j=0\n 9: getstatic #2; \/\/Field java\/lang\/System.out:Ljava\/io\/PrintStream;\n 12: iload_1\n 13: invokevirtual #3; \/\/Method java\/io\/PrintStream.println:(I)V\n 16: getstatic #2; \/\/Field java\/lang\/System.out:Ljava\/io\/PrintStream;\n 19: iload_2\n 20: invokevirtual #3; \/\/Method java\/io\/PrintStream.println:(I)V\n 23: return\n<\/pre>\n<p>\u5f88\u660e\u663e\u53ef\u4ee5\u770b\u51fa\uff0cjava\u662f\u5148\u628ai\u7684\u503c\u53d6\u51fa\u6765\u653e\u5230\u6808\u9876\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba4\u4e3a\u662f\u5f15\u5165\u4e86\u7b2c\u4e09\u4e2a\u53d8\u91cfint k=i;\u7136\u540ei++,\u8fd9\u65f6\u5019i\u4e3a1\u4e86\uff0c\u7136\u540e\u8ba9j=k;\u4e5f\u5c31\u662f0.\u7ed3\u8bba\uff0ci\u7684++\u8fd0\u7b97\u662f\u5728\u5bf9j\u8fd9\u4e2a\u53d8\u91cf\u7684\u8d4b\u503c\u4e4b\u524d\u5b8c\u6210\u7684\u3002<br \/>\n\u4ee3\u78013\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">public class Test3{\n public static void main(String[] args){\n int i=0;\n int j=0;\n j=++i;\n System.out.println(i);\n System.out.println(j);\n }\n}\n<\/pre>\n<p>\u7ed3\u679c\u5927\u5bb6\u4e5f\u90fd\u77e5\u9053\uff0ci=1\uff0cj=1<br \/>\n\u770b\u64cd\u4f5c\u8fc7\u7a0b\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">public static void main(java.lang.String[]);\n Code:\n 0: iconst_0\n 1: istore_1 \/\/i=0\n 2: iconst_0\n 3: istore_2 \/\/j=0\n 4: iinc 1, 1 \/\/\u5c40\u90e8\u53d8\u91cfi\u52a01\uff0c\u8fd9\u65f6\u5019i\u53d8\u62101\u4e86 \u3002\n 7: iload_1 \/\/\u628ai\u7684\u503c\u653e\u5230\u6808\u9876,\u6808\u9876\u7684\u503c\u662f1\n 8: istore_2 \/\/j=1\n 9: getstatic #2; \/\/Field java\/lang\/System.out:Ljava\/io\/PrintStream;\n 12: iload_1\n 13: invokevirtual #3; \/\/Method java\/io\/PrintStream.println:(I)V\n 16: getstatic #2; \/\/Field java\/lang\/System.out:Ljava\/io\/PrintStream;\n 19: iload_2\n 20: invokevirtual #3; \/\/Method java\/io\/PrintStream.println:(I)V\n 23: return\n<\/pre>\n<p>\u5bf9\u6bd4\u4ee3\u78012\u548c\u4ee3\u78013\uff0c\u5173\u952e\u7684\u5dee\u522b\u5c31\u662fiload_1 \u00a0 \u4e2aiinc\u8fd9\u4e24\u6761\u6307\u4ee4\u7684\u4f4d\u7f6e\u53d8\u4e86\u3002<br \/>\n\u4e0a\u9762\u8fd9\u4e2a\u5e16\u5b50\u504f\u91cd\u4e8e\u5e95\u5c42\uff0c\u5bf9\u4e8ejava\u5b57\u8282\u7801\u4e0d\u719f\u6089\u7684\u7ae5\u978b\u53ef\u80fd\u4e00\u65f6\u4e0d\u4f1a\u7406\u89e3\uff0c\u6ca1\u5173\u7cfb\uff0c\u4e0b\u9762\u6211\u8d34\u51fa\u53e6\u4e00\u4e2a\u5e16\u5b50\uff0c\u5927\u5bb6\u5e94\u8be5\u5c31\u660e\u767d\u4e86\uff1a<br \/>\n\u539f\u5e16\u5730\u5740\uff1a<a href=\"http:\/\/www.ticmy.com\/?p=43\">http:\/\/www.ticmy.com\/?p=43<\/a><\/p>\n<div id=\"highlighter_509510\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>\n<div><code>int<\/code> <code>i = <\/code><code>0<\/code><code>;<\/code><\/div>\n<div><code>i = i++;<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u7ed3\u679c\u8fd8\u662f0<br \/>\n\u4e3a\u4ec0\u4e48\uff1f<br \/>\n\u7a0b\u5e8f\u7684\u6267\u884c\u987a\u5e8f\u662f\u8fd9\u6837\u7684\uff1a\u56e0\u4e3a++\u5728\u540e\u9762\uff0c\u6240\u4ee5\u5148\u4f7f\u7528i\uff0c\u201c\u4f7f\u7528\u201d\u7684\u542b\u4e49\u5c31\u662fi++\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c\u662f0\uff0c\u4f46\u662f\u5e76\u6ca1\u6709\u505a\u8d4b\u503c\u64cd\u4f5c\uff0c\u5b83\u5728\u6574\u4e2a\u8bed\u53e5\u7684\u6700\u540e\u624d\u505a\u8d4b\u503c\uff0c\u4e5f\u5c31\u662f\u8bf4\u5728\u505a\u4e86++\u64cd\u4f5c\u540e\u518d\u8d4b\u503c\u7684\uff0c\u6240\u4ee5\u6700\u7ec8\u7ed3\u679c\u8fd8\u662f0<br \/>\n\u8ba9\u6211\u4eec\u770b\u7684\u66f4\u6e05\u6670\u70b9\uff1a<\/p>\n<div>\n<div id=\"highlighter_815038\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>\n<div><code>int<\/code> <code>i = <\/code><code>0<\/code><code>;<\/code><code>\/\/\u8fd9\u4e2a\u6ca1\u4ec0\u4e48\u8bf4\u7684<\/code><\/div>\n<div><code>i = i++;<\/code><code>\/\/\u7b49\u6548\u4e8e\u4e0b\u9762\u7684\u8bed\u53e5\uff1a<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div id=\"highlighter_861960\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>\n<div><code>int<\/code> <code>temp = i;<\/code><code>\/\/\u8fd9\u4e2atemp\u5c31\u662fi++\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c<\/code><\/div>\n<div><code>i++; <\/code><code>\/\/i\u81ea\u589e<\/code><\/div>\n<div><code>i = temp;<\/code><code>\/\/\u6700\u7ec8\uff0c\u5c06\u8868\u8fbe\u5f0f\u7684\u503c\u8d4b\u503c\u7ed9i<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u8fd9\u662fjava\u91cc\u7684\u5b9e\u73b0\uff0c\u5f53\u7136\u5728\u5176\u4ed6\u7684\u8bed\u8a00\u5982c\u6216\u662fc++\u4e2d\u53ef\u80fd\u5e76\u4e0d\u662f\u8fd9\u4e48\u5904\u7406\u7684\uff0c\u6bcf\u79cd\u8bed\u8a00\u90fd\u6709\u5404\u81ea\u7684\u7406\u7531\u53bb\u505a\u76f8\u5e94\u7684\u5904\u7406\u3002<br \/>\n\u8fd9\u8b66\u793a\u6211\u4eec:\u4e0d\u8981\u5728\u5355\u4e2a\u7684\u8868\u8fbe\u5f0f\u4e2d\u5bf9\u76f8\u540c\u7684\u53d8\u91cf\u8d4b\u503c\u8d85\u8fc7\u4e00\u6b21<br \/>\n\u8ba9\u6211\u4eec\u4ece\u5b57\u8282\u7801\u5c42\u6b21\u770b\u4e00\u770b\uff0c\u6e90\u7801\u5982\u4e0b\uff1a<\/p>\n<div>\n<div id=\"highlighter_748787\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>\n<div><code>public<\/code> <code>class<\/code> <code>Test {<\/code><\/div>\n<div><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0<\/code><code>public<\/code> <code>static<\/code> <code>void<\/code> <code>main(String... args) {<\/code><\/div>\n<div><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>int<\/code> <code>i = <\/code><code>0<\/code><code>;<\/code><\/div>\n<div><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>i = i++;<\/code><\/div>\n<div><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>System.out.println(i);<\/code><\/div>\n<div><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0<\/code><code>}<\/code><\/div>\n<div><code>}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u4f7f\u7528javac\u7f16\u8bd1\u540e\u518d\u4f7f\u7528javap -c Test\u53cd\u7f16\u8bd1\u8fd9\u4e2a\u7c7b\u67e5\u770b\u5b83\u7684\u5b57\u8282\u7801\uff0c\u5982\u4e0b\uff08\u53ea\u6458\u53d6main\u65b9\u6cd5\uff09\uff1a<br \/>\npublic static void main(java.lang.String[]);<br \/>\nCode:<br \/>\n0: iconst_0<br \/>\n1: istore_1<br \/>\n2: iload_1<br \/>\n3: iinc 1, 1<br \/>\n6: istore_1<br \/>\n7: getstatic #2; \/\/Field java\/lang\/System.out:Ljava\/io\/PrintStream;<br \/>\n10: iload_1<br \/>\n11: invokevirtual #3; \/\/Method java\/io\/PrintStream.println:(I)V<br \/>\n14: return<br \/>\n\u8fd9\u91cc\uff0c\u6211\u4ece\u7b2c0\u884c\u5f00\u59cb\u5206\u6790\uff08\u5206\u6790\u4e2d\u3010\u3011\u8868\u793a\u6808\uff0c\u6808\u7684\u5e95\u7aef\u5728\u5de6\u8fb9\uff0c\u9876\u7aef\u5728\u53f3\u8fb9\uff09\uff1a<br \/>\n0\uff1a\u5c06\u5e38\u65700\u538b\u5165\u6808\uff0c\u6808\u5185\u5bb9\uff1a\u30100\u3011<br \/>\n1\uff1a\u5c06\u6808\u9876\u7684\u5143\u7d20\u5f39\u51fa\uff0c\u4e5f\u5c31\u662f0\uff0c\u4fdd\u5b58\u5230\u5c40\u90e8\u53d8\u91cf\u533a\u7d22\u5f15\u4e3a\u4e3a1\uff08\u4e5f\u5c31\u662f\u53d8\u91cfi\uff09\u7684\u5730\u65b9\u3002\u6808\u5185\u5bb9\uff1a\u3010\u3011<br \/>\n2\uff1a\u5c06\u5c40\u90e8\u53d8\u91cf\u533a\u7d22\u5f15\u4e3a1\uff08\u4e5f\u5c31\u662f\u53d8\u91cfi\uff09\u7684\u503c\u538b\u5165\u6808\uff0c\u6808\u5185\u5bb9\uff1a\u30100\u3011<br \/>\n3\uff1a\u5c06\u5c40\u90e8\u53d8\u91cf\u533a\u7d22\u5f15\u4e3a1\uff08\u4e5f\u5c31\u662f\u5e38\u91cfi\uff09\u7684\u503c\u52a0\u4e00\uff0c\u6b64\u65f6\u5c40\u90e8\u53d8\u91cf\u533a\u7d22\u5f15\u4e3a1\u7684\u503c\uff08\u4e5f\u5c31\u662fi\u7684\u503c\uff09\u662f1\u3002\u6808\u5185\u5bb9\uff1a\u30100\u3011<br \/>\n6\uff1a\u5c06\u6808\u9876\u5143\u7d20\u5f39\u51fa\uff0c\u4fdd\u5b58\u5230\u5c40\u90e8\u53d8\u91cf\u533a\u7d22\u5f15\u4e3a1\uff08\u4e5f\u5c31\u662fi\uff09\u7684\u5730\u65b9\uff0c\u6b64\u65f6i\u53c8\u53d8\u6210\u4e860\u3002\u6808\u5185\u5bb9\uff1a\u3010\u3011<br \/>\n7\uff1a\u83b7\u53d6\u5e38\u91cf\u6c60\u4e2d\u7d22\u5f15\u4e3a2\u6240\u8868\u793a\u7684\u7c7b\u53d8\u91cf\uff0c\u4e5f\u5c31\u662fSystem.out\u3002\u6808\u5143\u7d20\uff1a\u3010\u3011<br \/>\n10\uff1a\u5c06\u5c40\u90e8\u53d8\u91cf\u533a\u7d22\u5f15\u4e3a1\u7684\u503c\uff08\u4e5f\u5c31\u662fi\uff09\u538b\u5165\u6808\u3002\u6808\u5143\u7d20\uff1a\u30100\u3011<br \/>\n11\uff1a\u8c03\u7528\u5e38\u91cf\u6c60\u7d22\u5f15\u4e3a3\u7684\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662fSystem.out.println<br \/>\n14\uff1a\u8fd4\u56demain\u65b9\u6cd5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u8fd9\u4e48\u4e00\u9053java\u9898\u76ee\uff0c\u8ba9\u4eba\u89c9\u5f97\u5f88\u8d39\u89e3\uff1a int i = 0; i = i++; System.out.pri <a href='http:\/\/prayerlaputa.com\/?p=58' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[6,12,19],"tags":[33,44,51],"_links":{"self":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/58"}],"collection":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=58"}],"version-history":[{"count":0,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions"}],"wp:attachment":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}