{"id":482,"date":"2019-03-06T10:41:36","date_gmt":"2019-03-06T02:41:36","guid":{"rendered":"https:\/\/fick707.com\/?p=482"},"modified":"2019-03-06T10:41:36","modified_gmt":"2019-03-06T02:41:36","slug":"java-throwabel-error-exception","status":"publish","type":"post","link":"https:\/\/fick707.com\/?p=482","title":{"rendered":"java throwabel error exception"},"content":{"rendered":"<p>https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425<\/p>\n<div class=\"toc\">\n<h3>\u6587\u7ae0\u76ee\u5f55<\/h3>\n<ul>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#Java_1\" target=\"_self\" rel=\"nofollow noopener noreferrer\">Java\u5f02\u5e38\u7c7b\u5c42\u6b21\u7ed3\u6784\u56fe<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#_4\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u4ec0\u4e48\u662f\u5f02\u5e38<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#Throwable_8\" target=\"_self\" rel=\"nofollow noopener noreferrer\">Throwable<\/a>\n<ul>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#Error_10\" target=\"_self\" rel=\"nofollow noopener noreferrer\">Error\uff08\u9519\u8bef\uff09<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#Exception_12\" target=\"_self\" rel=\"nofollow noopener noreferrer\">Exception\uff08\u5f02\u5e38\uff09<\/a>\n<ul>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#unchecked_exception_14\" target=\"_self\" rel=\"nofollow noopener noreferrer\">unchecked exception\uff08**\u975e\u68c0\u67e5**\u5f02\u5e38\uff09<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#checked_exception_16\" target=\"_self\" rel=\"nofollow noopener noreferrer\">checked exception\uff08**\u68c0\u67e5**\u5f02\u5e38\uff0c\u7f16\u8bd1\u5f02\u5e38\uff09<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#_19\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u533a\u522b<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#catch_25\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u5e94\u8be5catch\u4ec0\u4e48<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/mccand1234\/article\/details\/51579425#Errorcatch_catch_37\" target=\"_self\" rel=\"nofollow noopener noreferrer\">Error\u53ef\u4ee5catch\u5417\uff1f \u53ef\u4ee5catch\u4e86\u540e\u505a\u4e9b\u5176\u4ed6\u5904\u7406\u5417\uff1f<\/a><\/li>\n<\/ul>\n<\/div>\n<h1><a name=\"t1\"><\/a><a id=\"Java_1\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>Java\u5f02\u5e38\u7c7b\u5c42\u6b21\u7ed3\u6784\u56fe<\/h1>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdn.net\/20160603151809323\" alt=\"\u8fd9\u91cc\u5199\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h1><a name=\"t2\"><\/a><a id=\"_4\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>\u4ec0\u4e48\u662f\u5f02\u5e38<\/h1>\n<p><strong>\u5f02\u5e38<\/strong>\u7684\u82f1\u6587\u5355\u8bcd\u662fexception\uff0c\u5b57\u9762\u7ffb\u8bd1\u5c31\u662f\u201c\u610f\u5916\u3001\u4f8b\u5916\u201d\u7684\u610f\u601d\uff0c\u4e5f\u5c31\u662f\u975e\u6b63\u5e38\u60c5\u51b5\u3002\u4e8b\u5b9e\u4e0a\uff0c\u5f02\u5e38\u672c\u8d28\u4e0a<span style=\"color: red;\">\u662f\u7a0b\u5e8f\u4e0a\u7684\u9519\u8bef\uff0c\u5305\u62ec\u7a0b\u5e8f\u903b\u8f91\u9519\u8bef\u548c\u7cfb\u7edf\u9519\u8bef\u3002\u6bd4\u5982\u4f7f\u7528\u7a7a\u7684\u5f15\u7528\u3001\u6570\u7ec4\u4e0b\u6807\u8d8a\u754c\u3001\u5185\u5b58\u6ea2\u51fa\u9519\u8bef\u7b49\uff0c\u8fd9\u4e9b\u90fd\u662f\u610f\u5916\u7684\u60c5\u51b5\uff0c\u80cc\u79bb\u6211\u4eec\u7a0b\u5e8f\u672c\u8eab\u7684\u610f\u56fe<\/span>\u3002\u9519\u8bef\u5728\u6211\u4eec\u7f16\u5199\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u4e2d\u4f1a\u7ecf\u5e38\u53d1\u751f\uff0c\u5305\u62ec\u7f16\u8bd1\u671f\u95f4\u548c\u8fd0\u884c\u671f\u95f4\u7684\u9519\u8bef\uff0c\u5728<span style=\"color: red;\">\u7f16\u8bd1\u671f\u95f4<\/span>\u51fa\u73b0\u7684\u9519\u8bef\u6709\u7f16\u8bd1\u5668\u5e2e\u52a9\u6211\u4eec\u4e00\u8d77\u4fee\u6b63\uff0c\u7136\u800c<span style=\"color: red;\">\u8fd0\u884c\u671f\u95f4<\/span>\u7684\u9519\u8bef\u4fbf\u4e0d\u662f\u7f16\u8bd1\u5668<a href=\"https:\/\/www.baidu.com\/s?wd=%E5%8A%9B%E6%89%80&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd\" target=\"_blank\" rel=\"noopener noreferrer\">\u529b\u6240<\/a>\u80fd\u53ca\u4e86\uff0c\u5e76\u4e14\u8fd0\u884c\u671f\u95f4\u7684\u9519\u8bef\u5f80\u5f80\u662f<a href=\"https:\/\/www.baidu.com\/s?wd=%E9%9A%BE%E4%BB%A5%E9%A2%84%E6%96%99&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd\" target=\"_blank\" rel=\"noopener noreferrer\">\u96be\u4ee5\u9884\u6599<\/a>\u7684\u3002\u5047\u82e5\u7a0b\u5e8f\u5728\u8fd0\u884c\u671f\u95f4\u51fa\u73b0\u4e86\u9519\u8bef\uff0c\u5982\u679c<a href=\"https:\/\/www.baidu.com\/s?wd=%E7%BD%AE%E4%B9%8B%E4%B8%8D%E7%90%86&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd\" target=\"_blank\" rel=\"noopener noreferrer\">\u7f6e\u4e4b\u4e0d\u7406<\/a>\uff0c\u7a0b\u5e8f\u4fbf\u4f1a\u7ec8\u6b62\u6216\u76f4\u63a5\u5bfc\u81f4\u7cfb\u7edf\u5d29\u6e83\uff0c\u663e\u7136\u8fd9\u4e0d\u662f\u6211\u4eec\u5e0c\u671b\u770b\u5230\u7684\u7ed3\u679c\u3002\u56e0\u6b64\uff0c\u5982\u4f55\u5bf9\u8fd0\u884c\u671f\u95f4\u51fa\u73b0\u7684\u9519\u8bef\u8fdb\u884c\u5904\u7406\u548c\u8865\u6551\u5462\uff1fJava\u63d0\u4f9b\u4e86\u5f02\u5e38\u673a\u5236\u6765\u8fdb\u884c\u5904\u7406\uff0c\u901a\u8fc7\u5f02\u5e38\u673a\u5236\u6765\u5904\u7406\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u51fa\u73b0\u7684\u9519\u8bef\u3002\u901a\u8fc7\u5f02\u5e38\u673a\u5236\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u597d\u5730\u63d0\u5347\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u3002<\/p>\n<h1><a name=\"t3\"><\/a><a id=\"Throwable_8\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>Throwable<\/h1>\n<p>\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u5b50\u7c7b\uff1aException\uff08\u5f02\u5e38\uff09\u548c Error\uff08\u9519\u8bef\uff09\uff0c\u4e8c\u8005\u90fd\u662f Java \u5f02\u5e38\u5904\u7406\u7684\u91cd\u8981\u5b50\u7c7b\uff0c\u5404\u81ea\u90fd\u5305\u542b\u5927\u91cf\u5b50\u7c7b\u3002<\/p>\n<h2><a name=\"t4\"><\/a><a id=\"Error_10\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>Error\uff08\u9519\u8bef\uff09<\/h2>\n<p>\u662f\u7a0b\u5e8f\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u8868\u793a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8f83\u4e25\u91cd\u95ee\u9898\u3002<span style=\"color: red;\">\u5927\u591a\u6570\u9519\u8bef\u4e0e\u4ee3\u7801\u7f16\u5199\u8005\u6267\u884c\u7684\u64cd\u4f5c\u65e0\u5173\uff0c\u800c\u8868\u793a\u4ee3\u7801\u8fd0\u884c\u65f6\u00a0<strong>JVM\uff08Java \u865a\u62df\u673a\uff09\u51fa\u73b0\u7684\u95ee\u9898<\/strong>\u3002<\/span>\u4f8b\u5982\uff0cJava\u865a\u62df\u673a\u8fd0\u884c\u9519\u8bef\uff08Virtual MachineError\uff09\uff0c\u5f53 JVM \u4e0d\u518d\u6709\u7ee7\u7eed\u6267\u884c\u64cd\u4f5c\u6240\u9700\u7684\u5185\u5b58\u8d44\u6e90\u65f6\uff0c\u5c06\u51fa\u73b0 OutOfMemoryError\u3002\u8fd9\u4e9b\u5f02\u5e38\u53d1\u751f\u65f6\uff0cJava\u865a\u62df\u673a\uff08JVM\uff09\u4e00\u822c\u4f1a\u9009\u62e9\u7ebf\u7a0b\u7ec8\u6b62\u3002\u8fd9\u4e9b\u9519\u8bef\u8868\u793a\u6545\u969c\u53d1\u751f\u4e8e\u865a\u62df\u673a\u81ea\u8eab\u3001\u6216\u8005\u53d1\u751f\u5728\u865a\u62df\u673a\u8bd5\u56fe\u6267\u884c\u5e94\u7528\u65f6\uff0c\u5982Java\u865a\u62df\u673a\u8fd0\u884c\u9519\u8bef\uff08Virtual MachineError\uff09\u3001\u7c7b\u5b9a\u4e49\u9519\u8bef\uff08NoClassDefFoundError\uff09\u7b49\u3002\u8fd9\u4e9b\u9519\u8bef\u662f\u4e0d\u53ef\u67e5\u7684\uff0c\u56e0\u4e3a\u5b83\u4eec\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u63a7\u5236\u548c\u5904\u7406\u80fd\u529b\u4e4b \u5916\uff0c\u800c\u4e14\u7edd\u5927\u591a\u6570\u662f\u7a0b\u5e8f\u8fd0\u884c\u65f6\u4e0d\u5141\u8bb8\u51fa\u73b0\u7684\u72b6\u51b5\u3002\u5bf9\u4e8e\u8bbe\u8ba1\u5408\u7406\u7684\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\uff0c\u5373\u4f7f\u786e\u5b9e\u53d1\u751f\u4e86\u9519\u8bef\uff0c\u672c\u8d28\u4e0a\u4e5f\u4e0d\u5e94\u8be5\u8bd5\u56fe\u53bb\u5904\u7406\u5b83\u6240\u5f15\u8d77\u7684\u5f02\u5e38\u72b6\u51b5\u3002\u5728 Java\u4e2d\uff0c\u9519\u8bef\u901a\u8fc7Error\u7684\u5b50\u7c7b\u63cf\u8ff0\u3002<\/p>\n<h2><a name=\"t5\"><\/a><a id=\"Exception_12\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>Exception\uff08\u5f02\u5e38\uff09<\/h2>\n<p>\u662f\u7a0b\u5e8f\u672c\u8eab\u53ef\u4ee5\u5904\u7406\u7684\u5f02\u5e38\u3002Exception \u7c7b\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u5b50\u7c7b\u00a0<strong>RuntimeException<\/strong>\u3002<span style=\"color: red;\">RuntimeException \u7c7b\u53ca\u5176\u5b50\u7c7b\u8868\u793a\u201cJVM \u5e38\u7528\u64cd\u4f5c\u201d\u5f15\u53d1\u7684\u9519\u8bef<\/span>\u3002\u4f8b\u5982\uff0c\u82e5\u8bd5\u56fe\u4f7f\u7528\u7a7a\u503c\u5bf9\u8c61\u5f15\u7528\u3001\u9664\u6570\u4e3a\u96f6\u6216\u6570\u7ec4\u8d8a\u754c\uff0c\u5219\u5206\u522b\u5f15\u53d1\u8fd0\u884c\u65f6\u5f02\u5e38\uff08NullPointerException\u3001ArithmeticException\uff09\u548c ArrayIndexOutOfBoundException\u3002<\/p>\n<h3><a name=\"t6\"><\/a><a id=\"unchecked_exception_14\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>unchecked exception\uff08<strong>\u975e\u68c0\u67e5<\/strong>\u5f02\u5e38\uff09<\/h3>\n<p>\u4e5f\u79f0\u8fd0\u884c\u65f6\u5f02\u5e38\uff08RuntimeException\uff09\uff0c\u6bd4\u5982\u5e38\u89c1\u7684NullPointerException\u3001IndexOutOfBoundsException\u3002\u5bf9\u4e8e\u8fd0\u884c\u65f6\u5f02\u5e38\uff0cjava\u7f16\u8bd1\u5668<strong>\u4e0d\u8981\u6c42<\/strong>\u5fc5\u987b\u8fdb\u884c\u5f02\u5e38\u6355\u83b7\u5904\u7406\u6216\u8005\u629b\u51fa\u58f0\u660e\uff0c\u7531\u7a0b\u5e8f\u5458\u81ea\u884c\u51b3\u5b9a\u3002<\/p>\n<h3><a name=\"t7\"><\/a><a id=\"checked_exception_16\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>checked exception\uff08<strong>\u68c0\u67e5<\/strong>\u5f02\u5e38\uff0c\u7f16\u8bd1\u5f02\u5e38\uff09<\/h3>\n<p>\u4e5f\u79f0\u975e\u8fd0\u884c\u65f6\u5f02\u5e38\uff08\u8fd0\u884c\u65f6\u5f02\u5e38\u4ee5\u5916\u7684\u5f02\u5e38\u5c31\u662f\u975e\u8fd0\u884c\u65f6\u5f02\u5e38\uff09\uff0cjava\u7f16\u8bd1\u5668***\u5f3a\u5236\u7a0b\u5e8f\u5458***\u5fc5\u987b\u8fdb\u884c\u6355\u83b7\u5904\u7406\uff0c\u6bd4\u5982\u5e38\u89c1\u7684IOExeption\u548cSQLException\u3002\u5bf9\u4e8e\u975e\u8fd0\u884c\u65f6\u5f02\u5e38\u5982\u679c\u4e0d\u8fdb\u884c\u6355\u83b7\u6216\u8005\u629b\u51fa\u58f0\u660e\u5904\u7406\uff0c\u7f16\u8bd1\u90fd\u4e0d\u4f1a\u901a\u8fc7\u3002<\/p>\n<h2><a name=\"t8\"><\/a><a id=\"_19\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>\u533a\u522b<\/h2>\n<p>\u6ce8\u610f\uff1a\u5f02\u5e38\u548c\u9519\u8bef\u7684\u533a\u522b\uff1a<span style=\"color: red;\">\u5f02\u5e38\u80fd\u88ab\u7a0b\u5e8f\u672c\u8eab\u53ef\u4ee5\u5904\u7406\uff0c\u9519\u8bef\u662f\u65e0\u6cd5\u5904\u7406<\/span>\u3002\u901a\u5e38\uff0cJava\u7684\u5f02\u5e38(\u5305\u62ecException\u548cError)\u5206\u4e3a\u53ef\u67e5\u7684\u5f02\u5e38\uff08checked exceptions\uff09\u548c\u4e0d\u53ef\u67e5\u7684\u5f02\u5e38\uff08unchecked exceptions\uff09\u3002<br \/>\n\u53ef\u67e5\u5f02\u5e38\uff08\u7f16\u8bd1\u5668\u8981\u6c42\u5fc5\u987b\u5904\u7f6e\u7684\u5f02\u5e38\uff09\uff1a\u6b63\u786e\u7684\u7a0b\u5e8f\u5728\u8fd0\u884c\u4e2d\uff0c\u5f88\u5bb9\u6613\u51fa\u73b0\u7684\u3001\u60c5\u7406\u53ef\u5bb9\u7684\u5f02\u5e38\u72b6\u51b5\u3002\u53ef\u67e5\u5f02\u5e38\u867d\u7136\u662f\u5f02\u5e38\u72b6\u51b5\uff0c\u4f46\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u5b83\u7684\u53d1\u751f\u662f\u53ef\u4ee5\u9884\u8ba1\u7684\uff0c\u800c\u4e14\u4e00\u65e6\u53d1\u751f\u8fd9\u79cd\u5f02\u5e38\u72b6\u51b5\uff0c\u5c31\u5fc5\u987b\u91c7\u53d6\u67d0\u79cd\u65b9\u5f0f\u8fdb\u884c\u5904\u7406\u3002<br \/>\n\u9664\u4e86RuntimeException\u53ca\u5176\u5b50\u7c7b\u4ee5\u5916\uff0c\u5176\u4ed6\u7684Exception\u7c7b\u53ca\u5176\u5b50\u7c7b\u90fd\u5c5e\u4e8e\u53ef\u67e5\u5f02\u5e38\u3002\u8fd9\u79cd\u5f02\u5e38\u7684\u7279\u70b9\u662fJava\u7f16\u8bd1\u5668\u4f1a\u68c0\u67e5\u5b83\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5f53\u7a0b\u5e8f\u4e2d\u53ef\u80fd\u51fa\u73b0\u8fd9\u7c7b\u5f02\u5e38\uff0c\u8981\u4e48\u7528try-catch\u8bed\u53e5\u6355\u83b7\u5b83\uff0c\u8981\u4e48\u7528throws\u5b50\u53e5\u58f0\u660e\u629b\u51fa\u5b83\uff0c\u5426\u5219\u7f16\u8bd1\u4e0d\u4f1a\u901a\u8fc7\u3002<\/p>\n<h1><a name=\"t9\"><\/a><a id=\"catch_25\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>\u5e94\u8be5catch\u4ec0\u4e48<\/h1>\n<p>\u5176\u5b9e\u53ea\u8981\u662fThrowable\u548c\u5176\u5b50\u7c7b\u90fd\u662f\u53ef\u4ee5throw\u548ccatch\u7684\uff0c\u90a3\u4e48\u5982\u679c\u5728\u9700\u8981\u7edf\u4e00\u5904\u7406\u5f02\u5e38\u7684\u5730\u65b9\uff0c\u6211\u4eec\u5e94\u8be5catch (Throwable th) \u8fd8\u662f catch (Exception)\u5462\uff1f<br \/>\n\u8fd9\u4e24\u79cd\u5904\u7406\u7684\u533a\u522b\u5728\u4e8e\uff0ccatch throwable\u4f1a\u628aError\u548c\u5176\u4ed6\u7ee7\u627fThrowable\u7684\u7c7b\u6355\u6349\u5230\u3002\u800ccatch Exception\u53ea\u4f1a\u6355\u6349Exception\u6781\u5176\u5b50\u7c7b\uff0c\u6355\u6349\u7684\u8303\u56f4\u66f4\u5c0f\u3002\u5148\u4e0d\u8003\u8651\u6709\u5176\u4ed6\u7684\u7c7b\u7ee7\u627f\u4e86Throwable\u7684\u60c5\u51b5\u4e0b\uff0c\u7b2c\u4e00\u79cdcatch\u76f8\u5f53\u4e8e\u6bd4\u7b2c\u4e8c\u79cdcatch\u591a\u6355\u6349\u4e86\u628aError\u548c\u5176\u5b50\u7c7b\u3002<br \/>\n\u90a3\u4e48\u7a76\u7adfError\u662f\u5426\u9700\u8981\u6355\u6349\u5462\uff1fJDK\u4e2dError\u7c7b\u7684\u7684\u6ce8\u91ca\uff08\u5982\u4e0b\uff09\u91cc\u63d0\u5230\u8fc7\uff0c<span style=\"color: red;\">Error\u662f\u4e00\u79cd\u4e25\u91cd\u7684\u95ee\u9898\uff0c\u5e94\u7528\u7a0b\u5e8f\u4e0d\u5e94\u8be5\u6355\u6349\u5b83\u3002<\/span><br \/>\nAn Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a \u201cnormal\u201d condition, is also a subclass of Error because most applications should not try to catch it.<br \/>\nA method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur.<br \/>\nJava Lanuage Spec 7 \u4e2d\u4e5f\u63d0\u5230\uff1aError\u7ee7\u627f\u81eaThrowable\u800c\u4e0d\u662f\u7ee7\u627f\u81eaException\uff0c\u662f\u4e3a\u4e86\u65b9\u4fbf\u7a0b\u5e8f\u53ef\u4ee5\u4f7f\u7528 \u201ccatch (Exception)\u201c\u6765\u6355\u6349\u5f02\u5e38\u800c\u4e0d\u4f1a\u628aError\u4e5f\u6355\u6349\u5728\u5185\uff0c\u56e0\u4e3aException\u53d1\u751f\u540e\u53ef\u4ee5\u8fdb\u884c\u4e00\u4e9b\u6062\u590d\u5de5\u4f5c\u7684\uff0c\u4f46\u662fError\u53d1\u751f\u540e\u4e00\u822c\u662f\u4e0d\u53ef\u6062\u590d\u7684\u3002<br \/>\nThe class Error is a separate subclass ofThrowable, distinct from Exception in the class<br \/>\nhierarchy, to allow programs to use the idiom \u201c} catch (Exception e) { &#8221; (\u00a711.2.3)<br \/>\nto catch all exceptions from which recovery may be possible without catching errors from which recovery is typically not possible.<br \/>\n\u5df2\u7ecf\u4e0d\u96be\u770b\u51fa\uff0cJava\u672c\u8eab\u8bbe\u8ba1\u601d\u8def\u5c31\u662f\u5e0c\u671b\u5927\u5bb6catch Exception\u5c31\u8db3\u591f\u4e86\uff0c\u5982\u679c\u6709Error\u53d1\u751f\uff0ccatch\u4e86\u4e5f\u4e0d\u4f1a\u6709\u4ec0\u4e48\u4f5c\u7528\u3002<\/p>\n<h1><a name=\"t10\"><\/a><a id=\"Errorcatch_catch_37\" target=\"_blank\" rel=\"noopener noreferrer\"><\/a>Error\u53ef\u4ee5catch\u5417\uff1f \u53ef\u4ee5catch\u4e86\u540e\u505a\u4e9b\u5176\u4ed6\u5904\u7406\u5417\uff1f<\/h1>\n<p>Error\u662f\u53ef\u4ee5catch\u7684\uff0c\u800c\u4e14\u4e5f\u53ef\u4ee5\u5411\u5e38\u89c4Exception\u4e00\u6837\u88ab\u5904\u7406\uff0c\u800c\u4e14\u5c31\u7b97\u4e0d\u6355\u6349\u7684\u8bdd\u4e5f\u53ea\u662f\u5bfc\u81f4\u5f53\u524d\u7ebf\u7a0b\u6302\u6389\uff0c\u5176\u4ed6\u7ebf\u7a0b\u8fd8\u662f\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\uff0c\u5982\u679c\u6709\u9700\u8981\u7684\u8bdd\u6355\u6349Error\u4e4b\u540e\u4e5f\u53ef\u4ee5\u505a\u4e9b\u5176\u4ed6\u5904\u7406\u3002\u4f46\u662fError\u662f\u4e00\u79cd\u7cfb\u7edf\u5185\u90e8\u7684\u9519\u8bef\uff0c\u8fd9\u79cd\u9519\u8bef\u4e0d\u50cfException\u4e00\u6837\u662f\u53ef\u80fd\u662f\u7a0b\u5e8f\u548c\u4e1a\u52a1\u4e0a\u7684\u9519\u8bef\u662f\u53ef\u4ee5\u6062\u590d\u7684\u3002<\/p>\n<p>\u53c2\u8003\u94fe\u63a5\uff1a<br \/>\n<a href=\"http:\/\/blog.csdn.net\/hguisu\/article\/details\/6155636\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http:\/\/blog.csdn.net\/hguisu\/article\/details\/6155636<\/a><br \/>\n<a href=\"http:\/\/www.cnblogs.com\/dolphin0520\/p\/3769804.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http:\/\/www.cnblogs.com\/dolphin0520\/p\/3769804.html<\/a><br \/>\n<a href=\"http:\/\/doc.okbase.net\/foxty\/archive\/120046.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http:\/\/doc.okbase.net\/foxty\/archive\/120046.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/blog.csdn.net\/mccand1234\/article\/details\/5 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"series":[],"class_list":["post-482","post","type-post","status-publish","format-standard","hentry","category-programmers"],"_links":{"self":[{"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts\/482"}],"collection":[{"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=482"}],"version-history":[{"count":1,"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts\/482\/revisions"}],"predecessor-version":[{"id":483,"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts\/482\/revisions\/483"}],"wp:attachment":[{"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=482"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}