{"id":90,"date":"2015-10-27T21:53:53","date_gmt":"2015-10-27T13:53:53","guid":{"rendered":"http:\/\/dishudishu.com\/?p=90"},"modified":"2016-04-12T16:15:37","modified_gmt":"2016-04-12T08:15:37","slug":"java%e7%9a%84%e5%80%bc%e4%bc%a0%e9%80%92-%e5%bc%82%e5%b8%b8%e6%8a%9b%e5%87%ba","status":"publish","type":"post","link":"https:\/\/dishudishu.com\/?p=90","title":{"rendered":"java\u7684\u201c\u503c\u4f20\u9012\u201d + \u5f02\u5e38\u629b\u51fa"},"content":{"rendered":"<p>\u65b9\u6cd5\u8c03\u7528(call by)\uff08\u76f8\u5f53\u4e8ec++\u4e2d\u7684\u201c\u51fd\u6570\u8c03\u7528\u201d\uff09\uff0c\u6839\u636e\u53c2\u6570\u4f20\u9012\u7684\u60c5\u51b5\u5206\u4e3a\u503c\u8c03\u7528( call by reference ) \u548c\u5f15\u7528\u8c03\u7528( call by value ) \u3002<\/p>\n<p><strong>Java\u7684<span style=\"text-decoration: underline;\">\u5bf9\u8c61<\/span>\u53c2\u6570\u4f20\u9012\u4ecd\u7136\u662f\u503c\u8c03\u7528<\/strong>\uff0c\u8fd9\u91cc\u5f3a\u8c03\u7684\u662f\u201c\u5bf9\u8c61\u201d\u7684\u53c2\u6570\u4f20\u9012\u3002<\/p>\n<p>Java\u4e2d\u9664\u4e86<strong>primitive type<\/strong>\u4ee5\u5916\u4e00\u5207\u90fd\u662f\u5bf9\u8c61\u3002primitive type\u53ea\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a<a href=\"http:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027211946.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91\" src=\"http:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027211946.png\" alt=\"QQ\u56fe\u724720151027211946\" width=\"682\" height=\"431\" srcset=\"https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027211946.png 682w, https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027211946-300x190.png 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><\/p>\n<p>\u6ce8\u610f\uff0c\u5c31\u8fde\u6211\u4eec\u719f\u77e5\u7684\u6570\u7ec4\u6216\u8005String\u4e5f\u90fd\u662f\u5bf9\u8c61\u3002Java\u6ca1\u6709\u6307\u9488\uff0c\u6240\u4ee5\u5bf9primitive type\u5b9e\u73b0\u8457\u540d\u7684swap\u51fd\u6570\u5c31\u663e\u5f97\u6709\u4e9b\u56f0\u96be\uff0c\u4e00\u79cd\u53ef\u884c\u7684\u505a\u6cd5\u662f\u5148\u7279\u5730\u628a\u5b83\u4eec\u5305\u88c5\u6210\u5bf9\u8c61\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>Java\u4e2d\u5bf9\u8c61\u53d8\u91cf\u540d\u5b9e\u9645\u4e0a\u4ee3\u8868\u7684\u662f<span style=\"text-decoration: underline;\">\u5bf9\u8c61<\/span>\u5728\u5806\u4e2d\u7684\u5730\u5740(\u4e13\u4e1a\u672f\u8bed\u53eb\u505a<strong>\u5bf9\u8c61\u5f15\u7528 <\/strong>)\u3002\u5728Java\u65b9\u6cd5\u8c03\u7528\u7684\u65f6\u5019\uff0c\u53c2\u6570\u4f20\u9012\u7684\u662f<span style=\"text-decoration: underline;\">\u5bf9\u8c61\u7684\u5f15\u7528<\/span>\u3002\u91cd\u8981\u7684\u662f\uff0c\u5f62\u53c2\u548c\u5b9e\u53c2\u6240\u5360\u7684\u5185\u5b58\u5730\u5740\u5e76\u4e0d\u4e00\u6837\uff0c\u5f62\u53c2\u4e2d\u7684\u5185\u5bb9\u53ea\u662f\u5b9e\u53c2\u4e2d\u5b58\u50a8\u7684\u5bf9\u8c61\u5f15\u7528\u7684\u4e00\u4efd\u62f7\u8d1d\u3002\u8fd9\u6b63\u662f\u201c\u503c\u4f20\u9012\u201d\u7684\u8868\u73b0\u5f62\u5f0f\u3002<\/p>\n<p>\u901a\u8fc7\u4f20\u9012\u5bf9\u8c61\u5f15\u7528\uff0c\u5f62\u53c2\u548c\u5b9e\u53c2\u6307\u5411\u4e86\u540c\u4e00\u4e2a\u5730\u5740\u3002<strong>\u6240\u4ee5\u4fee\u6539\u5f62\u53c2\u7684\u6210\u5458\u53d8\u91cf\uff0c\u76f8\u5f53\u4e8e\u4fee\u6539\u4e86\u5b9e\u53c2\u7684<span style=\"text-decoration: underline;\">\u6210\u5458\u53d8\u91cf<\/span><\/strong>\u3002<\/p>\n<pre class=\"lang:java decode:true\">public class Employee {\r\n \r\n\tpublic String name=null;\r\n\t\r\n\tpublic Employee(String n){\r\n\t\tthis.name=n;\r\n\t}\r\n \r\n\tpublic static void Change(Employee e1,Employee e2){\r\n\t\te2.name = \"\u738b\u4e94\";\r\n\t\tSystem.out.println(e1.name+\" \"+e2.name); \/\/\u6253\u5370\u7ed3\u679c\uff1a\u5f20\u4e09 \u738b\u4e94\r\n\t}\r\n\t\/\/\u4e3b\u51fd\u6570\r\n\tpublic static void main(String[] args) {\r\n\t\tEmployee worker=new Employee(\"\u5f20\u4e09\");\r\n\t\tEmployee manager=new Employee(\"\u674e\u56db\");\r\n\t\tChange(worker,manager);\r\n\t\tSystem.out.println(worker.name+\" \"+manager.name); \r\n                \/\/\u6253\u5370\u7ed3\u679c\u4ecd\u7136\u662f\uff1a \u5f20\u4e09 \u738b\u4e94\r\n\t}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u8bd5\u7740\u5bf9\u4e00\u4e2a\u5bf9\u8c61\u5b9e\u73b0swap\u3002<\/p>\n<pre class=\"lang:java decode:true\">public class Employee {\r\n \r\n\tpublic String name=null;\r\n\t\r\n\tpublic Employee(String n){\r\n\t\tthis.name=n;\r\n\t}\r\n\t\/\/\u5c06\u4e24\u4e2aEmployee\u5bf9\u8c61\u4ea4\u6362\r\n\tpublic static void swap(Employee e1,Employee e2){\r\n\t\tEmployee temp=e1;\r\n\t\te1=e2;\r\n\t\te2=temp;\r\n\t\tSystem.out.println(e1.name+\" \"+e2.name); \/\/\u6253\u5370\u7ed3\u679c\uff1a\u674e\u56db \u5f20\u4e09\r\n\t\te2.name = \"\u738b\u4e94\";\r\n\t\tSystem.out.println(e1.name+\" \"+e2.name); \/\/\u6253\u5370\u7ed3\u679c\uff1a\u674e\u56db \u738b\u4e94\r\n\t}\r\n\t\/\/\u4e3b\u51fd\u6570\r\n\tpublic static void main(String[] args) {\r\n\t\tEmployee worker=new Employee(\"\u5f20\u4e09\");\r\n\t\tEmployee manager=new Employee(\"\u674e\u56db\");\r\n\t\tswap(worker,manager);\r\n\t\tSystem.out.println(worker.name+\" \"+manager.name); \r\n                \/\/\u6253\u5370\u7ed3\u679c\u4ecd\u7136\u662f\uff1a \u5f20\u4e09 \u674e\u56db\r\n\t}\r\n}<\/pre>\n<p>\u4ea4\u6362\u5931\u8d25\u3002\u524d\u9762\u8bf4\u5230\u5f62\u53c2\u548c\u5b9e\u53c2\u90fd\u662f\u5bf9\u8c61\u5f15\u7528\uff0c\u672c\u8d28\u4e0a\u662f\u5f15\u7528\uff0c\u90a3\u4e48\u4e0a\u9762\u90a3\u6bb5\u4ee3\u7801\u53ea\u662f\u628a\u5f62\u53c2\u7684\u4e24\u4e2a\u5f15\u7528\u4ea4\u6362\u4e86\u4e00\u4e0b\uff08\u76f8\u5f53\u4e8ec++\u4e2d\uff0c\u53ea\u662f\u4ea4\u6362\u4e86\u6307\u9488\uff0c\u800c\u4e0d\u662f\u4ea4\u6362\u6307\u9488\u6240\u6307\u5411\u7684\u5185\u5bb9\uff09\uff0c\u5bf9\u5b9e\u53c2\u7684\u60c5\u51b5\u6beb\u65e0\u5f71\u54cd\u3002\u4e0b\u9762\u7528\u56fe\u7ed9\u51fa\u76f4\u89c2\u7684\u63cf\u8ff0\uff1a<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-92\" src=\"http:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027213817.png\" alt=\"QQ\u56fe\u724720151027213817\" width=\"538\" height=\"314\" srcset=\"https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027213817.png 538w, https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027213817-300x175.png 300w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/p>\n<p>\u7531\u6b64\u53ef\u8fdb\u4e00\u6b65\u7406\u89e3\uff0c\u4e3a\u4ec0\u4e48\u8bf4JAVA\u672c\u8d28\u4e0a\u4ecd\u7136\u662f\u503c\u4f20\u9012\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0b\u9762\u8bb2\u8bb2\u5f02\u5e38\u629b\u51fa\u3002<\/p>\n<p>\u82e5\u8981\u5b9e\u73b0\u4ee5\u4e0b\u529f\u80fd\uff1a<\/p>\n<p><a href=\"http:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027214740.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-93\" src=\"http:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027214740.png\" alt=\"QQ\u56fe\u724720151027214740\" width=\"586\" height=\"80\" srcset=\"https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027214740.png 586w, https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151027214740-300x41.png 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/a><\/p>\n<p>\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff0c\u4f7f\u7528\u5f02\u5e38\u629b\u51fa\uff1a<\/p>\n<pre class=\"lang:java decode:true\">public class student{\r\n\r\n\t...\r\n\r\n\tpublic static void main(){\t\r\n\t\t\r\n\t\twhile(markForMaths &lt; 0 || markForMaths &gt; 100 || markForEnglish &lt; 0 || markForEnglish &gt; 100 || markForScience &lt; 0 || markForScience &gt; 100){\r\n\t\t\tSystem.out.println(\"\u8bf7\u8f93\u5165\u5b66\u751f\u4e09\u95e8\u8bfe\u6210\u7ee9\uff08\u6570\u5b66\uff0c\u82f1\u8bed\uff0c\u79d1\u5b66\uff09\uff1a\");\r\n\t\t\tString tmp1 = in.next();\t\/\/\u8f93\u5165\u4e09\u4e2a\u6570\u5b57\uff0c\u4ee5\u9017\u53f7\u5206\u9694\r\n\t\t\tString []tmp2 = tmp1.split(\",\");\r\n\t\t\ttry{\r\n\t\t\t\tmarkForMaths = Integer.parseInt(tmp2[0]);\r\n\t\t\t\tmarkForEnglish = Integer.parseInt(tmp2[1]);\r\n\t\t\t\tmarkForScience = Integer.parseInt(tmp2[2]);\r\n\t\t\t\tif(markForMaths &lt; 0 || markForMaths &gt; 100 || markForEnglish &lt; 0 || markForEnglish &gt; 100 || markForScience &lt; 0 || markForScience &gt; 100)\r\n\t\t\t\t\tthrow new ScoreException();\r\n\t\t\t}\r\n\t\t\tcatch(ScoreException e){\r\n\t\t\t\tSystem.out.println(e);\r\n\t\t\t}\r\n\t\t\tcatch(IOException e){\r\n\t\t\t\tSystem.out.println(e);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\t...\r\n\t\r\n}<\/pre>\n<pre class=\"lang:java decode:true\">public class ScoreException extends IOException {\r\n\tpublic ScoreException(){\r\n\t\tsuper(\"\u6210\u7ee9\u6570\u636e\u6709\u8bef\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\");\r\n\t}\r\n}<\/pre>\n<p>\u7b2c\u4e8c\u79cd\u5199\u6cd5\uff0c\u4e0d\u4f7f\u7528\u5f02\u5e38\u629b\u51fa\uff1a<\/p>\n<pre class=\"lang:java decode:true\">public class student{\r\n\r\n\t...\r\n\r\n\tpublic static void main(){\t\r\n\t\t\r\n\t\twhile(true){\r\n\t\t\tSystem.out.println(\"\u8bf7\u8f93\u5165\u5b66\u751f\u4e09\u95e8\u8bfe\u6210\u7ee9\uff08\u6570\u5b66\uff0c\u82f1\u8bed\uff0c\u79d1\u5b66\uff09\uff1a\");\r\n\t\t\tString tmp1 = in.next();\t\/\/\u8f93\u5165\u4e09\u4e2a\u6570\u5b57\uff0c\u4ee5\u9017\u53f7\u5206\u9694\r\n\t\t\tString []tmp2 = tmp1.split(\",\");\r\n\t\t\tmarkForMaths = Integer.parseInt(tmp2[0]);\r\n\t\t\tmarkForEnglish = Integer.parseInt(tmp2[1]);\r\n\t\t\tmarkForScience = Integer.parseInt(tmp2[2]);\r\n\t\t\tif(markForMaths &lt; 0 || markForMaths &gt; 100 || markForEnglish &lt; 0 || markForEnglish &gt; 100 || markForScience &lt; 0 || markForScience &gt; 100)\r\n\t\t\t\tbreak;\r\n\t\t\telse\r\n\t\t\t\tSystem.out.println(\"\u6210\u7ee9\u6570\u636e\u6709\u8bef\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\")\uff1b\r\n\t\t}\r\n\t}\r\n\t\r\n\t...\r\n\t\r\n}<\/pre>\n<p>\u663e\u7136\u7b2c\u4e8c\u79cd\u5199\u6cd5\u66f4\u7b80\u660e\u6e05\u6670\uff0c\u4e5f\u662f\u6211\u5728\u5b66\u5f02\u5e38\u629b\u51fa\u4e4b\u524d\u505a\u9519\u8bef\u5904\u7406\u4e00\u8d2f\u7684\u65b9\u5f0f\u3002\u8fd9\u96be\u9053\u8bf4\u660e\u5f02\u5e38\u629b\u51fa\u53cd\u800c\u662f\u7d2f\u8d58\u5417\uff1f\u4e0d\u662f\u7684\uff0c\u8fd9\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u5931\u8d25\u7684\u4f8b\u5b50\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u7b2c\u4e00\u79cd\u5199\u6cd5\u4e2d\uff0c\u65e2\u6ca1\u6709\u7528\u5230JAVA\u7684\u201c\u91cd\u65b0\u629b\u51fa\u5f02\u5e38\u201d\uff08\u5c31\u662f\u5728\u8fd9\u4e2a\u7c7b\u7684\u65b9\u6cd5\u5185\u90e8\u4e0d\u5904\u7406\u5f02\u5e38\uff0c\u800c\u662f\u4ea4\u7ed9\u8c03\u7528\u5b83\u7684\u90a3\u4e2a\u7c7b\u7684\u65b9\u6cd5\u53bb\u5904\u7406\uff0c\u4ece\u91cc\u9762\u4e00\u76f4\u5f80\u5916\u629b\uff0c \u7b80\u5355\u8bf4\u5c31\u662f\u8c01\u8c03\u7528\u8c01\u5904\u7406\u5f02\u5e38\uff0c\u6211\u4e0d\u7ba1\uff09\uff0c\u800c\u4e14\u4e5f\u53ea\u6709\u4e00\u5c42\u4ee3\u7801\uff0c\u4e8b\u5b9e\u4e0a\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5f88\u5c11\u5f3a\u884c\u4f7f\u7528\u5f02\u5e38\u629b\u51fa\u3002<\/p>\n<p>\u5f02\u5e38\u662f\u6709\u5c42\u7ea7\u5173\u7cfb\u7684\u9519\u8bef\u5904\u7406\u673a\u5236\uff0c\u662f\u4e13\u95e8\u62bd\u8c61\u51fa\u6765\u7684\u4e00\u4e2a\u7528\u6765\u5904\u7406\u9519\u8bef\u7684\u8bed\u6cd5\u3002\u5b50\u51fd\u6570\u5728\u51fa\u73b0\u5f02\u5e38\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u81ea\u5df1\u5904\u7406\u6389\uff0c\u4e5f\u53ef\u4ee5\u629b\u7ed9\u8c03\u7528\u8005\u5904\u7406\uff0c\u8fd8\u53ef\u4ee5\u81ea\u5df1\u5904\u7406\u4e00\u90e8\u5206\u8c03\u7528\u8005\u5904\u7406\u4e00\u90e8\u5206\u3002\u5904\u7406\u5f02\u5e38\u7684\u4ee3\u7801\u53ef\u4ee5\u975e\u5e38\u6e05\u6670\u5730\u4e0e\u903b\u8f91\u4e3b\u4f53\u9694\u7edd\u5f00\u6765\u3002\u5e76\u4e14\uff0cException\u88ab\u6355\u83b7\u7684\u8bdd\u5c31\u4e0d\u4f1a\u7ec8\u6b62\u7a0b\u5e8f\uff0c\u76f8\u6bd4\u4e4b\u4e0berror\u5219\u4f1a\u4f7f\u4e4b\u5b95\u6389\u3002<\/p>\n<p>\u53ef\u4ee5\u8bbe\u60f3\u8fd9\u4e48\u4e00\u4e2a\u573a\u666f\uff0c\u4f60\u5728\u67d0\u4e2a\u5730\u65b9\u8c03\u7528\u4e00\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\uff0c\u662f\u63a5\u53d7\u5b66\u751f\u6210\u7ee9\u5e76\u505a\u76f8\u5e94\u7684\u5904\u7406\u3002\u4f46\u662f\uff0c\u5982\u9898\u6240\u8bf4\uff0c\u8f93\u5165\u7684\u5b66\u751f\u6210\u7ee9\u53ef\u80fd\u662f\u9519\u8bef\u7684\u3002\u90a3\u4e48\u4f60\u5728\u8c03\u7528\u7684\u5730\u65b9\u600e\u4e48\u83b7\u53d6\u8fd9\u4e2a\u4fe1\u606f\u5462\uff1f\u4e24\u79cd\u529e\u6cd5\uff0c<strong>\u4e00\u79cd\u662f\u7528\u8fd4\u56de\u503c\u8868\u5f81\u72b6\u6001\uff0c\u4e00\u79cd\u662f\u7528\u5f02\u5e38\u5904\u7406\u673a\u5236<\/strong>\u3002\u6b64\u4f8b\u4e2d\u8fd4\u56de\u503c\u53ef\u4ee5\u6709\u4e24\u4e2a\u679a\u4e3e\u503c\uff0c0\u8868\u793a\u6b63\u5e38\uff0c1\u8868\u793a\u6210\u7ee9\u4e0d\u57280\u5230100\u7684\u95ed\u533a\u95f4\u5185\u3002<\/p>\n<p>\u7136\u800c\u5bf9\u4e8e\u66f4\u4e00\u822c\u7684\u60c5\u51b5\u6765\u8bf4\uff0c\u8fd4\u56de\u503c\u80fd\u8868\u793a\u7684\u4fe1\u606f\u5f88\u6709\u9650\uff0c\u4e5f\u5c31\u662f\uff0c\u53ea\u80fd\u8868\u793a\u9519\u8bef\u72b6\u6001\uff0c\u5374\u96be\u4ee5\u5c06\u66f4\u591a\u7684\u9519\u8bef\u4fe1\u606f\u8868\u8fbe\u51fa\u6765\u3002\u6bd4\u5982\u5982\u679c\u63a5\u53d7\u7684\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u90a3\u4e48\u4f60\u53ef\u80fd\u8fd8\u9700\u8981\u77e5\u9053\u8131\u79bb0\u5230100\u8303\u56f4\u7684\u6570\u7684\u4e0b\u6807\u662f\u591a\u5c11\u3002\u51fa\u73b0\u522b\u7684\u9519\u8bef\u65f6\uff0c\u4f60\u53ef\u80fd\u53c8\u60f3\u83b7\u53d6\u522b\u7684\u4fe1\u606f\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u8fd4\u56de\u503c\u5c31\u5f88\u96be\u505a\u5230\u4e86\u3002<\/p>\n<p>\u6240\u4ee5\u540e\u6765\u6211\u628a\u4ee3\u7801\u6539\u6210\u4e86\u8fd9\u4e2a\u6837\u5b50\uff1a<\/p>\n<pre class=\"lang:java decode:true\">public class student{\r\n\r\n\t...\r\n\r\n\tpublic static void main(){\t\r\n\t\tint score[] = new int[3];\r\n\t\tillegalFlag = true;\r\n\t\twhile(illegalFlag){\r\n\t\t\tillegalFlag = false;\r\n\t\t\tSystem.out.println(\"\u8bf7\u8f93\u5165\u5b66\u751f\u4e09\u95e8\u8bfe\u6210\u7ee9\uff08\u6570\u5b66\uff0c\u82f1\u8bed\uff0c\u79d1\u5b66\uff09\uff1a\");\t\t\t\r\n\t\t\ttry{\r\n\t\t\t\tgetScore(score);\r\n\t\t\t}\r\n\t\t\tcatch(_2013212130_zz_2_ScoreException e){\r\n\t\t\t\tSystem.out.println(e);\r\n\t\t\t}\r\n\t\t\tcatch(Exception e){\r\n\t\t\t\tSystem.out.println(\"\u8f93\u5165\u683c\u5f0f\u4e0d\u7b26\u5408\u8981\u6c42\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\");\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t...\r\n\t\r\n}<\/pre>\n<pre class=\"lang:java decode:true\">public static void getScore(int score[]) throws Exception{\r\n\t\tScanner in = new Scanner(new BufferedInputStream(System.in));\r\n\t\t\r\n\t\tString tmp1 = in.next();\r\n\t\tString []tmp2 = tmp1.split(\",\");\r\n\t\tint markForMaths = score[0] = Integer.parseInt(tmp2[0]);\r\n\t\tint markForEnglish = score[1] = Integer.parseInt(tmp2[1]);\r\n\t\tint markForScience = score[2] = Integer.parseInt(tmp2[2]);\r\n\t\tif(markForMaths &lt; 0 || markForMaths &gt; 100 || markForEnglish &lt; 0 || markForEnglish &gt; 100 || markForScience &lt; 0 || markForScience &gt; 100)\r\n\t\t\tthrow new _2013212130_zz_2_ScoreException();\r\n\t}<\/pre>\n<pre class=\"lang:java decode:true \">public class ScoreException extends IOException {\r\n\tpublic ScoreException(){\r\n\t\tsuper(\"\u6210\u7ee9\u6570\u636e\u6709\u8bef\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\");\r\n\t}\r\n}<\/pre>\n<p>\u8fd9\u6837\u624d\u4e0d\u4f1a\u80cc\u79bb\u201c\u5f02\u5e38\u5904\u7406\u201d\u7684\u539f\u5219\u592a\u8fdc\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u521d\u521d\u63a5\u89e6\u5f02\u5e38\u629b\u51fa\uff0c\u9664\u4e86\u660e\u767d\u57fa\u672c\u6982\u5ff5\uff0c\u6211\u611f\u89c9\u81ea\u5df1\u8fd8\u9700\u8981\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u8be5\u7528\u4ee5\u53ca\u8be5\u600e\u4e48\u7528\uff0c\u5728\u7f51\u4e0a\u627e\u5230\u4e86\u76f8\u5173\u6709\u8425\u517b\u7684\u5efa\u8bae\u3002<\/p>\n<p>1.\u53ea\u5728\u5fc5\u8981\u4f7f\u7528\u5f02\u5e38\u7684\u5730\u65b9\u624d\u4f7f\u7528\u5f02\u5e38\uff0c\u4e0d\u8981\u7528\u5f02\u5e38\u53bb\u63a7\u5236\u7a0b\u5e8f\u7684\u6d41\u7a0b\u3002\u8c28\u614e\u5730\u4f7f\u7528\u5f02\u5e38\uff0c\u5f02\u5e38\u6355\u83b7\u7684\u4ee3\u4ef7\u975e\u5e38\u9ad8\u6602\uff0c\u5f02\u5e38\u4f7f\u7528\u8fc7\u591a\u4f1a\u4e25\u91cd\u5f71\u54cd\u7a0b\u5e8f\u7684\u6027\u80fd\u3002<\/p>\n<p>2.\u5207\u5fcc\u4f7f\u7528\u7a7acatch\u5757\u3002\u5343\u4e07\u4e0d\u8981\u4f7f\u7528\u7a7a\u7684catch\u5757\uff0c\u7a7a\u7684catch\u5757\u610f\u5473\u7740\u4f60\u5728\u7a0b\u5e8f\u4e2d\u9690\u85cf\u4e86\u9519\u8bef\u548c\u5f02\u5e38\uff0c\u5e76\u4e14\u5f88\u53ef\u80fd\u5bfc\u81f4\u7a0b\u5e8f\u51fa\u73b0\u4e0d\u53ef\u63a7\u7684\u6267\u884c\u7ed3\u679c\u3002\u5982\u679c\u4f60\u975e\u5e38\u80af\u5b9a\u6355\u83b7\u5230\u7684\u5f02\u5e38\u4e0d\u4f1a\u4ee5\u4efb\u4f55\u65b9\u5f0f\u5bf9\u7a0b\u5e8f\u9020\u6210\u5f71\u54cd\uff0c\u6700\u597d\u7528Log\u65e5\u5fd7\u5c06\u8be5\u5f02\u5e38\u8fdb\u884c\u8bb0\u5f55\uff0c\u4ee5\u4fbf\u65e5\u540e\u65b9\u4fbf\u66f4\u65b0\u548c\u7ef4\u62a4\u3002<\/p>\n<p>3.\u4e0d\u8981\u5c06\u63d0\u4f9b\u7ed9\u7528\u6237\u770b\u7684\u4fe1\u606f\u653e\u5728\u5f02\u5e38\u4fe1\u606f\u91cc\u3002\u56e0\u4e3a\u4e1a\u52a1\u903b\u8f91\u8ddf\u7528\u6237\u754c\u9762\u8981\u89e3\u8026\u5408\uff0c\u5c55\u793a\u7ed9\u7528\u6237\u7684\u9519\u8bef\u63d0\u793a\u4fe1\u606f\u82e5\u5199\u6b7b\u5728\u91cc\u9762\u4e86\uff0c\u4e07\u4e00\u8981\u6539\u6210\u82f1\u6587\u7248\u7684\uff0c\u4e0d\u662f\u53c8\u5f97\u6539\u4e0b\u7a0b\u5e8f\uff1b\u4e07\u4e00\u4f60\u89c9\u5f97\u8fd9\u4e2apromt\u4e0d\u5408\u9002\uff0c\u60f3\u6362\u53e5\u597d\u542c\u70b9\u7684\u8bdd\uff0c\u53c8\u5f97\u6539\u4e0b\u7a0b\u5e8f\uff1b\u4e07\u4e00\u4f60\u8981\u652f\u6301\u591a\u8bed\u8a00\uff0c\u4f60\u8fd8\u5f97\u5728\u4ee3\u7801\u91cc\u9762\u6572\u8fdbN\u591a\u79cd\u8bed\u8a00\uff0c\u518d\u7528\u4e00\u4e2aswtich\u53bb\u62ff&#8230;<\/p>\n<p>\u5176\u4e2d\u4e00\u79cd\u505a\u6cd5\u662f\u62ff\u4e00\u4e2a\u00a0txt\u00a0\u6587\u4ef6\u6216\u8005\u00a0ini\u00a0\u6587\u4ef6\u4e4b\u7c7b\u7684\uff0c\u628a\u9519\u8bef\u7f16\u7801\u8ddf\u9519\u8bef\u63d0\u793a\u6587\u672c\u5b58\u8d77\u6765\u3002\u7136\u540e\u4e3b\u7a0b\u5e8f\u518d\u8dd1\u53bb\u6587\u4ef6\u91cc\u9762\u6839\u636e\u9519\u8bef\u7f16\u7801\u627e\u5230\u5177\u4f53\u7684\u5bf9\u5e94\u63d0\u793a\u6587\u672c\uff0c\u8fd9\u5c31\u662f\u4e00\u79cd<span style=\"text-decoration: underline;\">\u914d\u7f6e\u6587\u4ef6<\/span>\u3002\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><a href=\"http:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151028224530.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-97\" src=\"http:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151028224530.png\" alt=\"QQ\u56fe\u724720151028224530\" width=\"483\" height=\"101\" srcset=\"https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151028224530.png 483w, https:\/\/dishudishu.com\/wp-content\/uploads\/2015\/10\/QQ\u56fe\u724720151028224530-300x63.png 300w\" sizes=\"(max-width: 483px) 100vw, 483px\" \/><\/a><\/p>\n<p>4.\u907f\u514d\u591a\u6b21\u5728\u65e5\u5fd7\u4fe1\u606f\u4e2d\u8bb0\u5f55\u540c\u4e00\u4e2a\u5f02\u5e38\u3002\u53ea\u5728\u5f02\u5e38\u6700\u5f00\u59cb\u53d1\u751f\u7684\u5730\u65b9\u8fdb\u884c\u65e5\u5fd7\u4fe1\u606f\u8bb0\u5f55\u3002\u5f88\u591a\u60c5\u51b5\u4e0b\u5f02\u5e38\u90fd\u662f\u5c42\u5c42\u5411\u4e0a\u8dd1\u51fa\u7684\uff0c\u5982\u679c\u5728\u6bcf\u6b21\u5411\u4e0a\u629b\u51fa\u7684\u65f6\u5019\uff0c\u90fdLog\u5230\u65e5\u5fd7\u7cfb\u7edf\u4e2d\uff0c\u5219\u4f1a\u5bfc\u81f4\u65e0\u4ece\u67e5\u627e\u5f02\u5e38\u53d1\u751f\u7684\u6839\u6e90\u3002<\/p>\n<p>5.\u5f02\u5e38\u5904\u7406\u5c3d\u91cf\u653e\u5728\u9ad8\u5c42\u8fdb\u884c\u3002\u5c3d\u91cf\u5c06\u5f02\u5e38\u7edf\u4e00\u629b\u7ed9\u4e0a\u5c42\u8c03\u7528\u8005\uff0c\u7531\u4e0a\u5c42\u8c03\u7528\u8005\u7edf\u4e00\u4e4b\u65f6\u5982\u4f55\u8fdb\u884c\u5904\u7406\u3002\u5982\u679c\u5728\u6bcf\u4e2a\u51fa\u73b0\u5f02\u5e38\u7684\u5730\u65b9\u90fd\u76f4\u63a5\u8fdb\u884c\u5904\u7406\uff0c\u4f1a\u5bfc\u81f4\u7a0b\u5e8f\u5f02\u5e38\u5904\u7406\u6d41\u7a0b\u6df7\u4e71\uff0c\u4e0d\u5229\u4e8e\u540e\u671f\u7ef4\u62a4\u548c\u5f02\u5e38\u9519\u8bef\u6392\u67e5\u3002\u7531\u4e0a\u5c42\u7edf\u4e00\u8fdb\u884c\u5904\u7406\u4f1a\u4f7f\u5f97\u6574\u4e2a\u7a0b\u5e8f\u7684\u6d41\u7a0b\u6e05\u6670\u6613\u61c2\u3002<\/p>\n<p>6.\u5728finally\u4e2d\u91ca\u653e\u8d44\u6e90\u3002\u5982\u679c\u6709\u4f7f\u7528\u6587\u4ef6\u8bfb\u53d6\u3001\u7f51\u7edc\u64cd\u4f5c\u4ee5\u53ca\u6570\u636e\u5e93\u64cd\u4f5c\u7b49\uff0c\u8bb0\u5f97\u5728finally\u4e2d\u91ca\u653e\u8d44\u6e90\u3002\u8fd9\u6837\u4e0d\u4ec5\u4f1a\u4f7f\u5f97\u7a0b\u5e8f\u5360\u7528\u66f4\u5c11\u7684\u8d44\u6e90\uff0c\u4e5f\u4f1a\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u7531\u4e8e\u8d44\u6e90\u672a\u91ca\u653e\u800c\u53d1\u751f\u7684\u5f02\u5e38\u60c5\u51b5\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>reference\uff1a<\/p>\n<p><a href=\"http:\/\/qingyanxiyu.iteye.com\/blog\/745490\">Java\u76848\u79cd\u57fa\u672c\u6570\u636e\u7c7b\u578b(primitive Type)<\/a><\/p>\n<p><a href=\"http:\/\/hxraid.iteye.com\/blog\/428856\">\u3010\u89e3\u60d1\u3011Java\u65b9\u6cd5\u53c2\u6570\u662f\u5f15\u7528\u8c03\u7528\u8fd8\u662f\u503c\u8c03\u7528?<\/a><\/p>\n<p><a href=\"http:\/\/zhidao.baidu.com\/link?url=d25WY2NatqYSBDnec_JzGc1vKh5I1Fye_fhvGRmDr0-NP2lrCr6UEBZrbWQQWFGTjox4MTM7rSxLlWFIJhJ9ja\">JAVA\u5f02\u5e38\u91cd\u65b0\u629b\u51fa<\/a><\/p>\n<p class=\"postTitle\"><a id=\"cb_post_title_url\" class=\"postTitle2\" href=\"http:\/\/www.cnblogs.com\/dolphin0520\/p\/3769804.html\">Java\u5f02\u5e38\u5904\u7406\u548c\u8bbe\u8ba1<\/a><\/p>\n<p>\u4ee5\u53ca\uff0c\u4e0e@erueat\u7684\u804a\u5929<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6cd5\u8c03\u7528(call by)\uff08\u76f8\u5f53\u4e8ec++\u4e2d\u7684\u201c\u51fd\u6570\u8c03\u7528\u201d\uff09\uff0c\u6839\u636e\u53c2\u6570\u4f20\u9012\u7684\u60c5\u51b5\u5206\u4e3a\u503c\u8c03\u7528( call by r &hellip; <a href=\"https:\/\/dishudishu.com\/?p=90\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">java\u7684\u201c\u503c\u4f20\u9012\u201d + \u5f02\u5e38\u629b\u51fa<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"views":2708,"_links":{"self":[{"href":"https:\/\/dishudishu.com\/index.php?rest_route=\/wp\/v2\/posts\/90"}],"collection":[{"href":"https:\/\/dishudishu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dishudishu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dishudishu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dishudishu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":6,"href":"https:\/\/dishudishu.com\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":169,"href":"https:\/\/dishudishu.com\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions\/169"}],"wp:attachment":[{"href":"https:\/\/dishudishu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dishudishu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dishudishu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}