{"id":884,"date":"2018-11-06T12:00:35","date_gmt":"2018-11-06T03:00:35","guid":{"rendered":"https:\/\/www.bold.ne.jp\/engineer-club\/?p=884"},"modified":"2025-09-17T13:41:35","modified_gmt":"2025-09-17T04:41:35","slug":"java-try-catch","status":"publish","type":"post","link":"https:\/\/www.bold.ne.jp\/engineer-club\/java-try-catch","title":{"rendered":"Java\u306etry-catch\u6587\u3068\u306f\uff1f\u30a8\u30e9\u30fc\u51e6\u7406\u306b\u5bfe\u5fdc\u3059\u308b\u305f\u3081\u306etry-catch\u6587\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<p>Java\u306e<span>try-catch<\/span>\u6587\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u4e2d\u3067\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u304b\u8a66\u3057\u3066<span>(try)<\/span>\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u3089\u6355\u307e\u3048\u3066<span>(catch)<\/span>\u3001\u4f55\u304b\u3057\u3089\u306e\u51e6\u7406\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f<span>try<\/span>\u306e\u7528\u9014\u306e\u4e00\u3064\u300c\u4f8b\u5916\u51e6\u7406\u306e<span>try-catch<\/span>\u300d\u3092\u300c<span>Java<\/span>\u306e\u30a8\u30e9\u30fc\u51e6\u7406\u306f\u826f\u304f\u308f\u304b\u3089\u306a\u3044\u306a\u3041<span>\u2026<\/span>\u300d\u3068\u3044\u3046\u4eba\u5411\u3051\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<br \/>\n<span>try<\/span>\u304c\u95a2\u4fc2\u3059\u308b<span>try-finally<\/span>\u6587\u3084<span>try-with-resources<\/span>\u6587\u306b\u3082\u5c11\u3057\u3060\u3051\u89e6\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3092\u304a\u8aad\u307f\u306b\u306a\u308b\u65b9\u3068\u3057\u3066\u306f\u3001<span>Java<\/span>\u306e\u4f8b\u5916\u306b\u3064\u3044\u3066\u4e00\u5fdc\u306e\u77e5\u8b58\u304c\u3042\u308b\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3082\u3057\u81ea\u4fe1\u304c\u306a\u3044\u5834\u5408\u306f\u3001\u304a\u6301\u3061\u306e\u30c6\u30ad\u30b9\u30c8\u3084<span>WEB<\/span>\u306e\u8a18\u4e8b\u3067\u3042\u3089\u304b\u3058\u3081\u4e88\u7fd2\u3092\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u203b\u3053\u306e\u8a18\u4e8b\u306e\u30b5\u30f3\u30d7\u30eb\u306f\u3001<span>Java 10<\/span>\u306e\u74b0\u5883\u3067\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Javatry-catch\">\uff11\uff0e\u3010Java\u3011try-catch\u6587\u306f\u4f8b\u5916\u306b\u305d\u306e\u5834\u3067\u5bfe\u51e6\u3059\u308b\u6642\u306b\u4f7f\u3046<\/a><\/li><li><a href=\"#Javatry-catch-2\">\uff12\uff0e\u3010Java\u3011try-catch\u6587\u306e\u66f8\u304d\u65b9\u30fb\u4f7f\u3044\u65b9<\/a><ul><li><a href=\"#-try-catch\">\uff12-\uff11\uff0etry-catch\u6587\u306e\u57fa\u672c\u69cb\u6587<\/a><\/li><li><a href=\"#i\">\uff12-\uff12\uff0e\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u3068\u51e6\u7406\u306f\u4e2d\u65ad\u3055\u308c\u308b<\/a><\/li><li><a href=\"#-catch\">\uff12-\uff13\uff0e\u8907\u6570\u306e\u4f8b\u5916\u3092catch\u3057\u305f\u3044\u6642\u306f<\/a><\/li><li><a href=\"#-try-catch-2\">\uff12-\uff14\uff0etry-catch\u6587\u3092\u30cd\u30b9\u30c8\u3055\u305b\u305f\u6642\u306f<\/a><\/li><li><a href=\"#-catchthrow\">\uff12-\uff15\uff0ecatch\u3057\u305f\u4f8b\u5916\u3092throw\u3057\u305f\u3044\u5834\u5408<\/a><\/li><\/ul><\/li><li><a href=\"#Javatry-catch-3\">\uff13\uff0e\u3010Java\u3011try-catch\u6587\u3092\u4e0a\u624b\u306b\u6d3b\u7528\u3059\u308b\u305f\u3081\u306b<\/a><ul><li><a href=\"#-catch-2\">\uff13-\uff11\uff0e\u4f8b\u5916\u3092catch\u3057\u3066\u4f55\u3082\u3057\u306a\u3044\u306e\u306f\u53b3\u7981!<\/a><\/li><li><a href=\"#-RuntimeExceptionErrorcatch\">\uff13-\uff12\uff0e\u3010\u4e2d\u7d1a\u8005\u5411\u3051\u3011RuntimeException\u3084Error\u306ecatch\u306f\u5fc5\u8981\u306a\u6642\u3060\u3051!<\/a><\/li><li><a href=\"#-try\">\uff13-\uff13\uff0e\u3010\u4e2d\u7d1a\u8005\u5411\u3051\u3011try\u30d6\u30ed\u30c3\u30af\u306e\u7bc4\u56f2\u306f\u306a\u308b\u3079\u304f\u72ed\u304f\u3057\u3088\u3046!<\/a><\/li><\/ul><\/li><li><a href=\"#i-2\">\uff14\uff0e\u307e\u3068\u3081<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Javatry-catch\">\uff11\uff0e\u3010Java\u3011try-catch\u6587\u306f\u4f8b\u5916\u306b\u305d\u306e\u5834\u3067\u5bfe\u51e6\u3059\u308b\u6642\u306b\u4f7f\u3046<\/span><\/h2>\n<p>\u4e00\u822c\u7684\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u8a00\u3046\u30a8\u30e9\u30fc\u306f\u3001<span>Java<\/span>\u3067\u306f\u300c\u4f8b\u5916<span>(Exception)<\/span>\u300d\u3067\u8868\u73fe\u3055\u308c\u307e\u3059\u3002<span>Java<\/span>\u3067\u306f\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u7b87\u6240\u3067\u3001\u4f55\u304b\u3057\u3089\u306e\u5bfe\u51e6\u3092\u5fc5\u305a\u884c\u308f\u306a\u3051\u308c\u3070\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3093\u306a\u4f8b\u5916\u306b\u5bfe\u51e6\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u4e8c\u3064\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li><strong>\u305d\u306e\u5834\u3067\u30a8\u30e9\u30fc\u3078\u5bfe\u51e6\u3059\u308b\u2192try-catch\u6587\u3092\u4f7f\u3046<\/strong><\/li>\n<li><strong>\u305d\u306e\u5834\u3067\u306f\u4f8b\u5916\u3078\u306f\u5bfe\u51e6\u305b\u305a\u3001\u51e6\u7406\u3092\u4e2d\u65ad\u3057\u3066\u547c\u3073\u51fa\u3057\u5143\u306b\u4efb\u305b\u308b\u2192\u30e1\u30bd\u30c3\u30c9\u306ethrows\u7bc0\u3092\u4f7f\u3046<\/strong><\/li>\n<\/ol>\n<p>\u3067\u3082\u3001<span>throws<\/span>\u7bc0\u3092\u4f7f\u3063\u3066\u4f8b\u5916\u3078\u306e\u5bfe\u51e6\u3092\u547c\u3073\u51fa\u3057\u5143\u306e\u30e1\u30bd\u30c3\u30c9\u306b\u4efb\u305b\u3066\u3082\u3001\u7d50\u5c40\u305d\u3061\u3089\u3067\u540c\u3058\u4e8c\u629e\u3092\u8feb\u3089\u308c\u307e\u3059\u3002\u3067\u3059\u304b\u3089\u3001<span>Java<\/span>\u3067\u306f\u3069\u3053\u304b\u3067\u8ab0\u304b\u304c\u5fc5\u305a\u4f8b\u5916\u3078\u5bfe\u51e6\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001<span>Java<\/span>\u306e\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u7279\u5fb4\u306f\u3001\u767a\u751f\u3057\u3046\u308b\u4f8b\u5916\u3078\u306e\u5bfe\u51e6\u3092\u69cb\u6587\u4e0a\u3067\u5f37\u5236\u3055\u308c\u308b\u3053\u3068\u3067\u3059\u3002<span>C<\/span>\u8a00\u8a9e\u306a\u3069\u3067\u306f\u95a2\u6570\u306e\u623b\u308a\u5024\u3084\u5e83\u57df\u5909\u6570\u3067\u30a8\u30e9\u30fc\u306e\u767a\u751f\u6709\u7121\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u304c\u3001\u30c1\u30a7\u30c3\u30af\u306f\u3042\u304f\u307e\u3067\u4efb\u610f\u306a\u306e\u3067\u8a18\u8ff0\u3057\u5fd8\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u4f8b\u5916\u306f\u3001\u305d\u3093\u306a\u5fd8\u308c\u304c\u3061\u306a\u30a8\u30e9\u30fc\u51e6\u7406\u3092\u69cb\u6587\u4e0a\u3067\u5fc5\u9808\u306b\u3057\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30e1\u30bd\u30c3\u30c9\u306e\u623b\u308a\u5024\u306f\u30e1\u30bd\u30c3\u30c9\u304c\u672c\u6765\u623b\u3059\u3079\u304d\u30e2\u30ce\u3060\u3051\u306b\u5358\u7d14\u5316\u3057\u3001\u30a8\u30e9\u30fc\u306f\u4f8b\u5916\u3068\u3057\u3066\u5225\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u8868\u73fe\u3059\u308b\u3001\u3068\u3044\u3046\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30bf\u30a4\u30eb\u3067\u3082\u3042\u308a\u307e\u3059\u3002\u623b\u308a\u5024\u306b\u51e6\u7406\u7d50\u679c\u3068\u30a8\u30e9\u30fc\u6709\u7121\u304c\u7d44\u307f\u5408\u308f\u3055\u3063\u305f\u5f62\u5f0f\u3060\u3068\u3001\u547c\u3073\u51fa\u3057\u5074\u3067\u7d50\u679c\u3092\u89e3\u91c8\u3059\u308b\u51e6\u7406\u304c\u5225\u306b\u5fc5\u8981\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u3002<\/p>\n<h2><span id=\"Javatry-catch-2\">\uff12\uff0e\u3010Java\u3011try-catch\u6587\u306e\u66f8\u304d\u65b9\u30fb\u4f7f\u3044\u65b9<\/span><\/h2>\n<h3><span id=\"-try-catch\">\uff12-\uff11\uff0etry-catch\u6587\u306e\u57fa\u672c\u69cb\u6587<\/span><\/h3>\n<p>try-catch\u6587\u306ftry\u30d6\u30ed\u30c3\u30af\u3068catch\u30d6\u30ed\u30c3\u30af\u3092\u7e4b\u3052\u305f\u3082\u306e\u3067\u3059\u3002\u30d6\u30ed\u30c3\u30af\u3068\u306f{}\u3067\u56f2\u307e\u308c\u305f\u7bc4\u56f2\u3092\u6307\u3059\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u306e\u7528\u8a9e\u3067\u3059\u3002<\/p>\n<p>try\u30d6\u30ed\u30c3\u30af\u3067\u306f\u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u7406\u3092\u66f8\u304d\u307e\u3059\u3002\u3082\u3057<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u5185\u3067\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u306a\u3089\u3001<span>Java<\/span>\u304c\u305d\u306e\u4f8b\u5916\u3092\u6355\u307e\u3048\u3066\u3001<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u306b\u51e6\u7406\u3092\u79fb\u3057\u307e\u3059\u3002<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u5185\u306b\u306f\u88dc\u8db3\u3057\u305f\u4f8b\u5916\u3078\u306e\u51e6\u7406\u3092\u66f8\u3044\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>catch\u30d6\u30ed\u30c3\u30af\u306e\u5909\u6570\u5ba3\u8a00\u90e8\u5206\u3067\u306f\u3001<span>Throwable<\/span>\u3042\u308b\u3044\u306f<span>Throwable<\/span>\u3092\u7d99\u627f\u3057\u305f\u30af\u30e9\u30b9\u30fb\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3060\u3051\u3092\u578b\u306b\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002\u666e\u901a\u306e\u30af\u30e9\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3082\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u306f\u4f8b\u5916\u3092\u51e6\u7406\u3059\u308b\u305f\u3081\u306b\u3042\u308b\u3001\u4f8b\u5916\u5c02\u7528\u306e\u30d6\u30ed\u30c3\u30af\u3060\u304b\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u7406\r\n} catch (\u6355\u307e\u3048\u308b\u4f8b\u5916\u306e\u578b \u4f8b\u5916\u306e\u5909\u6570\u540d) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u51e6\u7406\r\n}<\/pre>\n<p>\u4f8b\u3068\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u6642\u306b\u767a\u751f\u3059\u308b\u4f8b\u5916\u3078\u5bfe\u51e6\u3057\u3066\u307f\u307e\u3059\u3002<span>java.io.FileReader<\/span>\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u306f\u4f8b\u5916<span>FileNotFoundException<\/span>\u304c\u767a\u751f\u3057\u3046\u308b\u3068\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e<span>throws<\/span>\u7bc0\u3067\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3067\u3059\u306e\u3067\u3001\u3053\u308c\u306b<span>try-catch<\/span>\u6587\u3067\u5bfe\u51e6\u3059\u308b\u306a\u3089\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ FileReader.read\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5ba3\u8a00(String\u3092\u5f15\u6570\u306b\u3068\u308b\u3082\u306e)\r\npublic FileReader(String fileName) throws FileNotFoundException<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\tFileReader fr = new FileReader(\"\/A\/B\/C\/D.txt\"); \/\/ \u3053\u3053\u3067\u767a\u751f\u3057\u3046\u308bFileNotFoundException\u3092\u2026\r\n} catch (FileNotFoundException e) { \/\/ \u3053\u3053\u3067catch\u3057\u3066\u2026\r\n\tSystem.out.println(\"\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308a\u307e\u305b\u3093!!\"); \/\/ \u4f55\u304b\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u7406\u3092\u884c\u3046!!\r\n}<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001\u4f8b\u5916\u306e\u5909\u6570\u540d\u306f\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u597d\u304d\u306b\u3067\u304d\u307e\u3059\u304c\u3001\u5358\u306b<span>&#8220;e&#8221;<\/span>\u3068\u3059\u308b\u306e\u304c\u5e83\u304f\u898b\u3089\u308c\u308b\u30b9\u30bf\u30a4\u30eb\u3067\u3001<span>JDK<\/span>\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u3082\u540c\u3058\u3067\u3059\u3002<span>e<\/span>\u306e\u4ed6\u306b\u306f<span>ex<\/span>\u3082\u826f\u304f\u898b\u307e\u3059\u304c\u3001<span>exception<\/span>\u306e\u3088\u3046\u306a\u9577\u3044\u5909\u6570\u540d\u306f\u307b\u3068\u3093\u3069\u898b\u304b\u3051\u307e\u305b\u3093\u3002\u660e\u78ba\u306a\u3082\u306e\u3078\u306f\u5358\u7d14\u306a\u3082\u306e\u306b\u3059\u308b\u306e\u304c\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u5171\u901a\u898b\u89e3\u3067\u3059\u3002<\/p>\n<h3><span id=\"i\">\uff12-\uff12\uff0e\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u3068\u51e6\u7406\u306f\u4e2d\u65ad\u3055\u308c\u308b<\/span><\/h3>\n<p>\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u6642\u70b9\u3067\u3001<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u5185\u306e\u51e6\u7406\u306f\u5373\u5ea7\u306b\u4e2d\u65ad\u3055\u308c\u3066<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u306b\u51e6\u7406\u304c\u79fb\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u3001\u51e6\u7406\u306e\u5b9f\u884c\u9806\u5e8f\u306f<span>\u2460\u2192\u2461\u2192\u2463\u2192\u2464<\/span>\u3068\u306a\u308a\u3001<span>\u2462<\/span>\u306f\u5b9f\u884c\u3055\u308c\u307e\u305b\u3093\u3002\u4f8b\u5916\u304c\u9014\u4e2d\u3067\u767a\u751f\u3057\u306a\u3051\u308c\u3070<span>\u2460\u2192\u2461\u2192\u2462\u2192\u2464<\/span>\u3068\u306a\u308a\u3001<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u306e\u5185\u5bb9<span>(\u2463)<\/span>\u306f\u5b9f\u884c\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">System.out.println(\"\u2460\");\r\n\r\ntry {\r\n\tSystem.out.println(\"\u2461\");\r\n\tif (true) { \/\/ \u203bif\u6587\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3059\u308b\u305f\u3081\u3067\u3001\u5b9f\u969b\u306b\u306f\u4e0d\u8981\r\n\t\tthrow new Exception(); \/\/ \u4f8b\u5916\u304c\u767a\u751f!!\r\n\t}\r\n\tSystem.out.println(\"\u2462\");\r\n} catch (Exception e) {\r\n\tSystem.out.println(\"\u2463\");\r\n}\r\n\r\nSystem.out.println(\"\u2464\");<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u672c\u6765\u884c\u3046\u306f\u305a\u3060\u3063\u305f\u51e6\u7406\u306e\u9014\u4e2d\u3067\u4e2d\u65ad\u3055\u308c\u307e\u3059\u3002\u3067\u3059\u304b\u3089\u3001\u4f8b\u3048\u3070<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u5185\u3067\u958b\u3044\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u9589\u3058\u308b\u306a\u3069\u306e\u5fc5\u8981\u306a\u5f8c\u51e6\u7406\u3092\u5fd8\u308c\u306a\u3044\u3088\u3046\u306b\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u305d\u3046\u3057\u306a\u3044\u3068\u3001\u3044\u308f\u3086\u308b\u30ea\u30bd\u30fc\u30b9\u30ea\u30fc\u30af\u3084\u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u304c\u767a\u751f\u3057\u3048\u307e\u3059\u3002<\/p>\n<p>\u4e00\u822c\u7684\u306b\u306f<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u306e\u4e2d\u3067\u306f\u30ea\u30bd\u30fc\u30b9\u306e\u89e3\u653e\u51e6\u7406\u306f\u884c\u3044\u307e\u305b\u3093\u3002\u30ea\u30bd\u30fc\u30b9\u306e\u89e3\u653e\u306f\u6b63\u5e38\u7d42\u4e86\u3057\u305f\u6642\u306b\u3082\u884c\u3046\u5fc5\u8981\u304c\u3042\u308b\u3082\u306e\u3067\u3059\u304c\u3001<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u306e\u4e2d\u3067\u66f8\u3044\u3066\u3057\u307e\u3063\u3066\u306f\u6b63\u5e38\u7d42\u4e86\u6642\u306e\u30ea\u30bd\u30fc\u30b9\u89e3\u653e\u3092\u66f8\u304d\u5fd8\u308c\u308b\u6050\u308c\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u306b\u3001<span>finally<\/span>\u30d6\u30ed\u30c3\u30af\u3084<span>try-with-resources<\/span>\u6587\u3092\u7528\u3044\u3066\u3001\u51e6\u7406\u306e\u6b63\u5e38\u7d42\u4e86\u30fb\u4f8b\u5916\u767a\u751f\u306b\u95a2\u308f\u3089\u305a\u3001\u30ea\u30bd\u30fc\u30b9\u89e3\u653e\u3092\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u7c21\u5358\u306b\u3067\u3059\u304c\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002try-with-resources\u6587\u3067\u306f\u3001java.lang.AutoCloseable\u3092\u5b9f\u88c5\u3057\u305f\u30af\u30e9\u30b9\u306a\u3089\u3001try\u304c\u7d42\u308f\u3063\u305f\u969b\u306b\u5fc5\u305aAutoCloseable.close()\u3092\u5b9f\u884c\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ finally\u53e5\u3092\u7528\u3044\u308b\u4f8b\r\nFileReader fr = null;\r\n\r\ntry {\r\n\tfr = new FileReader(\"XXXX.txt\");\r\n} catch (Exception e) {\r\n\t\/\/ \u4f55\u304b\u306e\u4f8b\u5916\u5bfe\u51e6\u51e6\u7406\r\n} finally {\r\n\tif (fr != null) { \/\/ new\u3067\u304d\u3066\u3044\u306a\u3044\u5834\u5408\u304c\u3042\u308b\u306e\u3067null\u304b\u3069\u3046\u304b\u78ba\u8a8d\r\n\t\tfr.close(); \/\/ close\u3092\u5b9f\u884c(\u203b\u5b9f\u969b\u306b\u306fclose\u3067\u767a\u751f\u3059\u308bIOException\u3082catch\u3059\u308b\u5fc5\u8981\u3042\u308a)\r\n\t}\r\n}<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ try-with-resources\u6587\u3092\u7528\u3044\u308b\u4f8b\r\n\/\/ FileReader\u306fAutoClosable\u306a\u306e\u3067\u3001try\u7d42\u4e86\u5f8c\u306b\u5fc5\u305aclose\u3055\u308c\u308b\r\ntry (FileReader fr = new FileReader(\"XXXX.txt\")) {\r\n\t\/\/ \u4f55\u304b\u306e\u51e6\u7406\r\n} catch (Exception e) {\r\n\t\/\/ \u4f55\u304b\u306e\u4f8b\u5916\u5bfe\u51e6\u51e6\u7406\r\n}<\/pre>\n<h3><span id=\"-catch\">\uff12-\uff13\uff0e\u8907\u6570\u306e\u4f8b\u5916\u3092catch\u3057\u305f\u3044\u6642\u306f<\/span><\/h3>\n<p>try-catch\u6587\u306e<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u3078\u306f\u3001<span>catch<\/span>\u3057\u305f\u3044\u4f8b\u5916\u3092\u3044\u304f\u3089\u3067\u3082\u7e4b\u3052\u3089\u308c\u307e\u3059\u3002\u305f\u3060\u3057\u5f8c\u8ff0\u3059\u308b\u7279\u5b9a\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\u3053\u3068\u304c\u5fc5\u8981\u3067\u3001\u3055\u3089\u306b\u540c\u3058\u4f8b\u5916\u306f\u7570\u306a\u308b<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u3067\u8907\u6570\u7e4b\u3052\u3089\u308c\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u7406\r\n} catch (\u6355\u307e\u3048\u308b\u4f8b\u5916\u306e\u30af\u30e9\u30b91 \u4f8b\u5916\u306e\u5909\u6570\u540d) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u51e6\u74061\r\n} catch (\u6355\u307e\u3048\u308b\u4f8b\u5916\u306e\u30af\u30e9\u30b92 \u4f8b\u5916\u306e\u5909\u6570\u540d) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u51e6\u74062\r\n} catch (\u6355\u307e\u3048\u308b\u4f8b\u5916\u306e\u30af\u30e9\u30b93 \u4f8b\u5916\u306e\u5909\u6570\u540d) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u51e6\u74063\r\n}<\/pre>\n<p>\u4f8b\u3068\u3057\u3066\u3001<span>FileReader<\/span>\u306e\u30e1\u30bd\u30c3\u30c9<span>read()<\/span>\u3067\u3084\u3063\u3066\u307f\u307e\u3059\u3002read()\u306f\u3001IOException\u3092throw\u3057\u307e\u3059\u3002\u3067\u3059\u306e\u3067\u3001FileReader\u3092new\u3057\u3066read\u3059\u308b\u969b\u306f\u3001FileNotFoundException\u3068IOException\u306e2\u3064\u306e\u4f8b\u5916\u3092\u6355\u6349\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ FileReader\u306e\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9InputStream\u3067\u306e\u3001\u30e1\u30bd\u30c3\u30c9read\u306e\u5ba3\u8a00\r\npublic int read() throws IOException<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\tFileReader fr = new FileReader(\"\/A\/B\/C\/D.txt\"); \/\/ FileNotFoundException\u304c\u767a\u751f\u3057\u3046\u308b\r\n\tint c = fr.read(); \/\/ IOException\u304c\u767a\u751f\u3057\u3046\u308b\r\n} catch (FileNotFoundException e) {\r\n\tSystem.out.println(\"\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308a\u307e\u305b\u3093!!\");\r\n} catch (IOException e) {\r\n\tSystem.out.println(\"\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\u306b\u5931\u6557\u3057\u307e\u3057\u305f!!\");\r\n}<\/pre>\n<p>\u3053\u3053\u3067\u3001<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u4e2d\u3067\u767a\u751f\u3057\u3046\u308b\u3051\u308c\u3069\u3082<span>catch<\/span>\u3055\u308c\u306a\u3044\u4f8b\u5916\u304c\u3042\u308b\u306a\u3089\u3001\u305d\u306e<span>try-catch<\/span>\u6587\u306e\u5916\u3067\u3001\u3069\u3053\u304b\u3067\u8ab0\u304b\u306b\u5bfe\u51e6\u3057\u3066\u3082\u3089\u308f\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u305d\u3046\u3057\u306a\u3044\u3068\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u3092\u89e3\u6d88\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ try\u30d6\u30ed\u30c3\u30af\u5185\u3067\u767a\u751f\u3057\u3046\u308bIOException\u304ccatch\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u307e\u307e\u3067\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!!\r\ntry {\r\n\tFileReader fr = new FileReader(\"\/A\/B\/C\/D.txt\"); \/\/ FileNotFoundException\u304c\u767a\u751f\u3057\u3046\u308b\r\n\tint c = fr.read(); \/\/ IOException\u304c\u767a\u751f\u3057\u3046\u308b\r\n} catch (FileNotFoundException e) {\r\n\tSystem.out.println(\"\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308a\u307e\u305b\u3093!!\");\r\n}<\/pre>\n<p>\u3055\u3066\u3001\u8907\u6570\u306e\u4f8b\u5916\u3092\u5bfe\u8c61\u3068\u3057\u305f<span>try-catch<\/span>\u6587\u306f\u3001<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u5185\u3067\u767a\u751f\u3057\u305f\u4f8b\u5916\u3078\u306e<span>switch<\/span>\u6587\u306e\u3088\u3046\u306a\u3082\u306e\u3060\u3068\u8003\u3048\u308b\u3068\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3057\u3087\u3046\u3002\u5177\u4f53\u7684\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u4f8b\u3067\u304a\u5206\u304b\u308a\u9802\u3051\u308b\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\tthrow new IllegalStateException(); \/\/ try\u30d6\u30ed\u30c3\u30af\u5185\u3067IllegalStateException\u304c\u767a\u751f!!\r\n} catch (NullPointerException e) {\r\n\t\/\/ \u3053\u3053\u306b\u306f\u6765\u306a\u3044\r\n\tSystem.out.println(\"NullPonterException\");\r\n} catch (IllegalStateException e) {\r\n\t\/\/ \u3053\u3053\u306b\u76f4\u63a5\u6765\u308b!!\r\n\tSystem.out.println(\"IllegalStateException\");\r\n} catch (IllegalArgumentException e) {\r\n\t\/\/ \u3053\u3053\u306b\u306f\u6765\u306a\u3044\r\n\tSystem.out.println(\"IllegalArgumentException\");\r\n}<\/pre>\n<h4>\uff12-\uff13-\uff11\uff0e\u4f8b\u5916\u306e\u7d99\u627f\u95a2\u4fc2\u306b\u306f\u3054\u6ce8\u610f\u3092<\/h4>\n<p>\u3061\u306a\u307f\u306b\u3001\u524d\u7bc0\u5192\u982d\u306e\u300c\u7279\u5b9a\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\u9650\u308a\u300d\u306f\u3001<span>catch<\/span>\u3057\u305f\u3044\u8907\u6570\u306e\u4f8b\u5916\u304c\u7d99\u627f\u95a2\u4fc2\u306b\u3042\u308b\u5834\u5408\u306b\u73fe\u308c\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u5916\u306e\u7d99\u627f\u95a2\u4fc2\u3067\u4e0a\u4f4d\u306b\u3042\u308b\u3082\u306e\u304c\u5148\u306b<span>catch<\/span>\u306b\u51fa\u3066\u304f\u308b\u3068\u3001\u305d\u306e\u5f8c\u306e<span>catch<\/span>\u3067\u306f\u4e0b\u4f4d\u306e\u30af\u30e9\u30b9\u3092\u6307\u5b9a\u3067\u304d\u307e\u305b\u3093\u3002\u305d\u3046\u3057\u305f\u5834\u5408\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001NullPointerException\u306fRuntimeException\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3059\u306e\u3067\u3001RuntimeException\u3092\u5148\u306bcatch\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u305d\u306e\u5f8c\u308d\u3067\u306f\u3082\u3046NullPointerException\u3092catch\u3067\u304d\u306a\u3044\u306e\u3067\u3059\u3002\u3053\u308c\u304cswtich\u3068\u306f\u9055\u3046\u3068\u3053\u308d\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ NG\u4f8b\uff1a\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9\u3092\u5148\u306bcatch\u3057\u3066\u3057\u307e\u3063\u305f\u30b1\u30fc\u30b9\r\ntry {\r\n\tthrow new NullPointerException(); \/\/ NullPointerException\u304cthrow\u3055\u308c\u305f\u6642\u306f\u2026\r\n} catch (RuntimeException e) {\r\n\t\/\/ \u3053\u3053\u306b\u6765\u308b\u3002NullPointerException\u306fRuntimeException\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3042\u308b\u305f\u3081\r\n\tSystem.out.println(\"RuntimeException\");\r\n} catch (NullPointerException e) {\r\n\t\/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! \u3053\u3053\u306b\u306f\u7d76\u5bfe\u306b\u6765\u3089\u308c\u306a\u3044\u305f\u3081\r\n\tSystem.out.println(\"NullPonterException\");\r\n}<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ OK\u4f8b\uff1a\u30b5\u30d6\u30af\u30e9\u30b9\u3092\u5148\u306bcatch\u3059\u308b\u30b1\u30fc\u30b9\r\ntry {\r\n\tthrow new NullPointerException(); \/\/ NullPointerException\u304cthrow\u3055\u308c\u305f\u6642\u306f\u2026\r\n} catch (NullPointerException e) {\r\n\t\/\/ NullPointerException\u3092\u5148\u306b\u66f8\u3051\u3070\u3001\u3053\u306ecatch\u306b\u6765\u308b\u3002\r\n\tSystem.out.println(\"NullPonterException\");\r\n} catch (Exception e) {\r\n\t\/\/ NullPointerException\u4ee5\u5916\u306e\u4f8b\u5916\u306f\u3053\u3053\u306b\u6765\u308b\r\n\tSystem.out.println(\"Exception\");\r\n}<\/pre>\n<p>\u4f8b\u5916\u306f\u4f55\u304b\u3057\u3089\u306e\u7d99\u627f\u95a2\u4fc2\u306b\u3042\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3001\u7279\u5b9a\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3092\u9078\u3093\u3067<span>catch<\/span>\u3057\u3066\u305d\u306e\u4f8b\u5916\u3060\u3051\u306e\u51e6\u7406\u3092\u884c\u3044\u3001\u305d\u308c\u4ee5\u5916\u306e\u4f8b\u5916\u306f\u540c\u3058\u51e6\u7406\u3092\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u5834\u5408\u306f\u3001<span>catch<\/span>\u3059\u308b\u4f8b\u5916\u306e\u9806\u5e8f\u306b\u6c17\u3092\u4ed8\u3051\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u540c\u3058\u3053\u3068\u306f\u3001<span>Exception<\/span>\u3084<span>Throwable<\/span>\u3067\u3082\u8a00\u3048\u307e\u3059\u3002\u3067\u3059\u304b\u3089\u3001\u4f8b\u5916\u306e\u7d99\u627f\u95a2\u4fc2\u3092\u77e5\u308b\u305f\u3081\u306b\u3082\u3001<span>API<\/span>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u306f\u76ee\u3092\u901a\u3057\u3066\u304a\u3044\u305f\u65b9\u304c\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f55\u304b\u306e\u51e6\u7406\r\n} catch (Throwable t) { \/\/ \u3053\u308c\u306f\u826f\u3044\u304c\u2026\r\n} catch (Error e) { \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! Error\u306fThrowable\u306e\u30b5\u30d6\u30af\u30e9\u30b9\r\n} catch (Exception e) { \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! Exception\u306fThrowable\u306e\u30b5\u30d6\u30af\u30e9\u30b9\r\n} catch (RuntimeException e) { \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! RuntimeException\u306fException\u306e\u30b5\u30d6\u30af\u30e9\u30b9\r\n} catch (NullPointerException e) { \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! NullPointerException\u306fRuntimeException\u306e\u30b5\u30d6\u30af\u30e9\u30b9\r\n}<\/pre>\n<h4>\uff12-\uff13-\uff12\uff0e\u8907\u6570\u306e\u4f8b\u5916\u30921\u3064\u306ecatch\u3067\u6355\u6349\u3059\u308b\u300c\u30de\u30eb\u30c1\u30ad\u30e3\u30c3\u30c1\u300d<\/h4>\n<p>\u306a\u304a\u3001<span>Java 7<\/span>\u304b\u3089\u30de\u30eb\u30c1\u30ad\u30e3\u30c3\u30c1<span>(multi-catch)<\/span>\u3068\u3044\u3046\u69cb\u6587\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002\u8907\u6570\u306e\u4f8b\u5916\u3067\u540c\u3058\u51e6\u7406\u3092\u3059\u308c\u3070\u3044\u3044\u306a\u3089\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u304c\u3067\u304d\u307e\u3059\u3002\u3064\u307e\u308a\u3001<span>catch<\/span>\u3057\u305f\u3044\u4f8b\u5916\u3078\u300c\u307e\u305f\u306f\u300d\u3068\u6307\u5b9a\u3059\u308b\u308f\u3051\u3067\u3059\u3002<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u3092\u305f\u304f\u3055\u3093\u7e26\u306b\u4e26\u3079\u306a\u304f\u3066\u3082\u3044\u3044\u306e\u3067\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u3059\u3063\u304d\u308a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u7406\r\n} catch (\u6355\u6349\u3059\u308b\u4f8b\u59161 | \u6355\u6349\u3059\u308b\u4f8b\u59162 | \u6355\u6349\u3059\u308b\u4f8b\u59163 \u4f8b\u5916\u306e\u5909\u6570\u540d) { \/\/ \u4f8b\u5916\u306f\u4efb\u610f\u306e\u6570\u3060\u3051\u66f8\u3051\u307e\u3059!\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u51e6\u7406\r\n}<\/pre>\n<p>\u305f\u3060\u3057\u3001\u30de\u30eb\u30c1\u30ad\u30e3\u30c3\u30c1\u3092\u4f7f\u3046\u3068\u3001\u4f8b\u5916\u306e\u5909\u6570\u306e\u5177\u4f53\u7684\u306a\u578b<span>(<\/span>\u3069\u306e\u30af\u30e9\u30b9\u3068\u3057\u3066\u6271\u308f\u308c\u308b\u304b<span>)<\/span>\u306f\u3001\u300c\u307e\u305f\u306f\u300d\u3067\u7e4b\u3052\u305f\u4f8b\u5916\u306e\u6700\u3082\u5171\u901a\u7684\u306a\u4f8b\u5916\u30af\u30e9\u30b9\u3068\u306a\u308a\u307e\u3059\u3002\u8a00\u8449\u3060\u3051\u3067\u306f\u5c11\u3057\u308f\u304b\u308a\u3065\u3089\u3044\u306e\u3067\u3001\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3067\u8a00\u3046\u3068\u3001NullPonterException\u3001IllegalStateException\u3001IllegalArgumentException\u3067\u5171\u901a\u306a\u306e\u306fRuntimeException\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3060\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3001RuntimeException\u6271\u3044\u3068\u306a\u308a\u307e\u3059\u3002\u3067\u3059\u304c\u3001FileNotFoundException \u3068 EOFException \u306f\u4e21\u65b9\u3068\u3082 IOException \u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3059\u304b\u3089\u3001IOException\u6271\u3044\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">import java.io.EOFException;\r\nimport java.io.FileNotFoundException;\r\nimport java.io.IOException;\r\n\r\nclass MultiCatchSample1 {\r\n\tpublic static void main(String[] args) {\r\n\t\ttry {\r\n\t\t\tthrowTooManyException();\r\n\t\t} catch (NullPointerException | IllegalStateException | IllegalArgumentException e) {\r\n\t\t\t\/\/ e\u306fRuntimeException\u6271\u3044\r\n\t\t\tSystem.out.println(e instanceof Exception); \/\/ \u2192 \u5e38\u306btrue\r\n\t\t\tSystem.out.println(e instanceof RuntimeException);  \/\/ \u2192 \u5e38\u306btrue\r\n\t\t\tSystem.out.println(e instanceof NullPointerException);  \/\/ \u2192 true\u306b\u306a\u308b\u304b\u306f\u72b6\u6cc1\u306b\u3088\u308b\r\n\t\t} catch (FileNotFoundException | EOFException e) {\r\n\t\t\t\/\/ e\u306fIOException\u6271\u3044\r\n\t\t}\r\n\t}\r\n\r\n\tstatic void throwTooManyException() throws NullPointerException, IllegalStateException, IllegalArgumentException,\r\n\t\t\tFileNotFoundException, EOFException {\r\n\t\tthrow new NullPointerException();\r\n\t}\r\n}<\/pre>\n<p>\u3053\u306e\u4f8b\u3060\u3068\u3001\u305d\u308c\u305e\u308c\u306e\u4f8b\u5916\u306b\u306f\u56fa\u6709\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u306a\u3044\u306e\u3067\u9055\u3044\u306f\u898b\u3048\u307e\u305b\u3093\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u56fa\u6709\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u3063\u305f\u5834\u5408\u306f\u5171\u901a\u3068\u306a\u308b\u4f8b\u5916\u306e\u3082\u306e\u3057\u304b\u6271\u3048\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">class MultiCatchSample2 {\r\n\tpublic static void main(String[] args) {\r\n\t\ttry {\r\n\t\t\tthrowTooManyException();\r\n\t\t} catch (SampleException1 | SampleException2 e) {\r\n\t\t\t\/\/ \u3053\u306e\u30b1\u30fc\u30b9\u3067\u306f\u3001e\u306fException\u6271\u3044\u3068\u306a\u308b\r\n\t\t\te.exceptionMethod1(); \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! \u3069\u3061\u3089\u306e\u4f8b\u5916\u304b\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u306f\u78ba\u5b9a\u3067\u304d\u306a\u3044\u305f\u3081\r\n\t\t\te.exceptionMethod2(); \/\/ \u540c\u4e0a\r\n\r\n\t\t\t\/\/ \u3053\u3046\u3059\u308b\u3053\u3068\u306f\u4e00\u5fdc\u3067\u304d\u308b\u304c\u3001\u672c\u672b\u8ee2\u5012\u304b\u3082\u3057\u308c\u306a\u3044\u2026\r\n\t\t\tif (e instanceof SampleException1) {\r\n\t\t\t\t((SampleException1) e).exceptionMethod1();\r\n\t\t\t} else if (e instanceof SampleException2) {\r\n\t\t\t\t((SampleException2) e).exceptionMethod2();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tstatic void throwTooManyException() throws SampleException1, SampleException2 {\r\n\t}\r\n\r\n\tstatic class SampleException1 extends Exception {\r\n\t\tvoid exceptionMethod1() {\r\n\t\t}\r\n\t}\r\n\r\n\tstatic class SampleException2 extends Exception {\r\n\t\tvoid exceptionMethod2() {\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<h3><span id=\"-try-catch-2\">\uff12-\uff14\uff0etry-catch\u6587\u3092\u30cd\u30b9\u30c8\u3055\u305b\u305f\u6642\u306f<\/span><\/h3>\n<p>try-catch\u6587\u306f\u30cd\u30b9\u30c8\u3067\u304d\u307e\u3059\u3002\u3064\u307e\u308a\u3001try-catch\u6587\u306e\u5185\u5074\u306b\u3082try-catch\u6587\u3092\u66f8\u3051\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u5185\u5074\u306e<span>try-catch<\/span>\u6587\u3067<span>catch<\/span>\u3055\u308c\u306a\u304b\u3063\u305f\u4f8b\u5916\u306f\u3001\u5916\u5074\u306e<span>try-catch<\/span>\u6587\u3067<span>catch<\/span>\u3067\u304d\u307e\u3059\u3002\u3082\u3057\u30cd\u30b9\u30c8\u3057\u3066\u3044\u308b\u3059\u3079\u3066\u306e<span>try-catch<\/span>\u6587\u3067\u5bfe\u8c61\u306e\u4f8b\u5916\u304c<span>catch<\/span>\u3055\u308c\u306a\u3044\u306e\u306a\u3089\u3001\u30e1\u30bd\u30c3\u30c9\u304b\u3089<span>throw<\/span>\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059<span>(throws<\/span>\u7bc0\u3078\u306e\u8a18\u8ff0\u304c\u5fc5\u8981<span>)<\/span>\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ try\u30d6\u30ed\u30c3\u30af\u5185\u3067\u30cd\u30b9\u30c8\u3059\u308b\u5834\u5408\r\ntry {\r\n\ttry {\r\n\t\tthrow new IOException();\r\n\t} catch (NullPointerException e) {\r\n\t\tSystem.out.println(\"NullPointerException!!\"); \/\/ \u3053\u3053\u3067IOException\u3092catch\u3057\u3066\u3044\u306a\u304f\u3066\u3082\u2026\r\n\t}\r\n} catch (IOException e) {\r\n\tSystem.out.println(\"IOException!!\"); \/\/ \u30cd\u30b9\u30c8\u5143\u3067catch\u3067\u304d\u308b!!\r\n}<\/pre>\n<p>\u305f\u3060\u3057\u3001\u5916\u5074\u306e<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u3084<span>finally<\/span>\u30d6\u30ed\u30c3\u30af\u306e\u4e2d\u3067\u767a\u751f\u3057\u305f\u4f8b\u5916\u306f\u3001\u305d\u306e\u30d6\u30ed\u30c3\u30af\u5185\u3067\u51e6\u7406\u3059\u308b\u304b\u3001\u30e1\u30bd\u30c3\u30c9\u304b\u3089<span>throw<\/span>\u3055\u308c\u306a\u304f\u3066\u306f\u306a\u308a\u307e\u305b\u3093\u3002\u305d\u306e\u6642\u70b9\u3067\u306f\u3001\u3082\u3046\u5916\u5074\u306e<span>try-catch<\/span>\u30d6\u30ed\u30c3\u30af\u3067\u306f\u6355\u6349\u3067\u304d\u306a\u3044\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\tthrow new IOException();\r\n} catch (IOException e) {\r\n\t\/\/ \u2193\u306ecatch\u30d6\u30ed\u30c3\u30af\u3084finally\u30d6\u30ed\u30c3\u30af\u5185\u3067\u767a\u751f\u3057\u305f\u4f8b\u5916\u306f\u3001\u3053\u3053\u3067\u6355\u6349\u3055\u308c\u306a\u3044\r\n} catch (Exception e) {\r\n\t\/\/ catch\u30d6\u30ed\u30c3\u30af\u5185\u3067\u30cd\u30b9\u30c8\u3059\u308b\u5834\u5408\r\n\ttry {\r\n\t\tthrow new IOException();\r\n\t} catch (IOException e2) {\r\n\t\tSystem.out.println(\"IOException in catch block!!\");\r\n\t}\r\n} finally {\r\n\t\/\/ finally\u30d6\u30ed\u30c3\u30af\u5185\u3067\u30cd\u30b9\u30c8\u3059\u308b\u5834\u5408\r\n\ttry {\r\n\t\tthrow new IOException();\r\n\t} catch (IOException e) {\r\n\t\tSystem.out.println(\"IOException in finally block!!\");\r\n\t}\r\n}<\/pre>\n<p>\u5916\u5074\u3068\u5185\u5074\u306e<span>try-catch<\/span>\u6587\u3067\u540c\u3058\u4f8b\u5916\u3092<span>catch<\/span>\u3059\u308b\u3088\u3046\u306b\u3057\u305f\u5834\u5408\u306f\u3001\u5185\u5074\u306e\u3082\u306e\u304c\u512a\u5148\u3055\u308c\u307e\u3059\u3002\u4e00\u3064\u306e<span>try-catch<\/span>\u6587\u3067\u51e6\u7406\u304c\u5b8c\u7d50\u3057\u3066\u3044\u308c\u3070\u3001\u5916\u5074\u3078\u306f\u6ce2\u53ca\u3057\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\ttry {\r\n\t\tthrow new NullPointerException();\r\n\t} catch (NullPointerException e) {\r\n\t\tSystem.out.println(\"NullPointerException in inner try-catch!!\"); \/\/ \u3053\u3053\u3067catch\u3055\u308c\u308b\r\n\t}\r\n} catch (NullPointerException e) {\r\n\tSystem.out.println(\"NullPointerException in outer try-catch!!\"); \/\/ \u3053\u3053\u3067catch\u3055\u308c\u308b\r\n}<\/pre>\n<p>\u306a\u304a\u3001\u30e1\u30bd\u30c3\u30c9\u306ethrows\u7bc0\u3092\u4f7f\u3046\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u3092\u8d85\u3048\u3066try-catch\u6587\u3092\u30cd\u30b9\u30c8\u3055\u305b\u3066\u3044\u308b\u306e\u3060\u3068\u8003\u3048\u308b\u3068\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002\u4f8b\u3048\u3070\u4ee5\u4e0b\u3060\u3068method2\u2192method1\u306e\u9806\u756a\u306b\u672a\u51e6\u7406\u306e\u4f8b\u5916\u304c\u4f1d\u308f\u308a\u3001\u3069\u3053\u304b\u306e\u8ab0\u304b\u304ccatch\u3059\u308b\u307e\u3067\u7d9a\u304f\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">\/\/ \u3053\u306e\u30bd\u30fc\u30b9\u65ad\u7247\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u306b\u306f\u901a\u308a\u307e\u305b\u3093\r\ntry {\r\n\tvoid method1() throws IOException { \/\/ \u2464\u7d50\u5c40\u3001method1\u3067\u3082IOException\u306f\u51e6\u7406\u305b\u305athrow\u3059\u308b\r\n\t\ttry {\r\n\t\t\tvoid method2() throws IOException { \/\/ \u2462method2\u3067\u306fIOException\u306f\u51e6\u7406\u305b\u305athrow\u3059\u308b\r\n\t\t\t\ttry {\r\n\t\t\t\t\tthrow new IOException(); \/\/ \u2460IOException\u304c\u767a\u751f!!\r\n\t\t\t\t} catch (NullPointerException e) {\r\n\t\t\t\t\t\/\/ \u2461\u3053\u3053\u306etry-catch\u6587\u3067\u306fIOException\u306fcatch\u3055\u308c\u305a\u3001\u547c\u3073\u51fa\u3057\u5143\u3078throw\u3055\u308c\u308b\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\t\/\/ \u2463\u3053\u3053\u3067\u3082IOException\u306fcatch\u3055\u308c\u305a\u3001\u3055\u3089\u306b\u547c\u3073\u51fa\u3057\u5143\u3078throw\u3055\u308c\u308b\r\n\t\t}\r\n\t}\r\n} catch (IOException e) {\r\n\t\/\/ \u2465\u3053\u3053\u306etry-catch\u6587\u3067\u3088\u3046\u3084\u304fcatch\u3055\u308c\u305f!!\r\n}<\/pre>\n<h3><span id=\"-catchthrow\">\uff12-\uff15\uff0ecatch\u3057\u305f\u4f8b\u5916\u3092<span>throw<\/span>\u3057\u305f\u3044\u5834\u5408<\/span><\/h3>\n<p>\u4e00\u5ea6<span>catch<\/span>\u3057\u305f\u4f8b\u5916\u3092<span>throw<\/span>\u3057\u3066\u3001\u547c\u3073\u51fa\u3057\u5143\u306b\u51e6\u7406\u3092\u4efb\u305b\u305f\u3044\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u5834\u3067\u306f\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u3068\u3044\u3046\u30ed\u30b0\u3060\u3051\u51fa\u529b\u3057\u305f\u3044\u5834\u5408\u306a\u3069\u3067\u3059\u3002\u305d\u306e\u5834\u5408\u306f\u3001<span>catch<\/span>\u5185\u3067\u4f8b\u5916\u3092<span>throw<\/span>\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\tthrow new IOException();\r\n} catch (IOException e) {\r\n\tSystem.out.println(\"IOException!!\"); \/\/ \u4f55\u304b\u306e\u51e6\u7406\u3092\u3084\u3063\u3066\u2026\r\n\tthrow e; \/\/ \u4f8b\u5916\u306e\u51e6\u7406\u81ea\u4f53\u306f\u547c\u3073\u51fa\u3057\u5143\u304b\u4ed6\u306etry-catch\u6587\u306b\u4efb\u305b\u308b\r\n}<\/pre>\n<p>\u5f53\u7136\u306a\u304c\u3089\u3001<span>throw<\/span>\u3055\u308c\u305f\u4f8b\u5916\u3078\u306f\u8ab0\u304b\u304c\u5bfe\u51e6\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u306e\u3067\u3001\u3055\u3089\u306b\u3053\u306e\u5916\u5074\u306b<span>try-catch<\/span>\u6587\u3092\u66f8\u304f\u304b\u3001\u30e1\u30bd\u30c3\u30c9\u306e<span>throws<\/span>\u7bc0\u306b<span>throw<\/span>\u3057\u305f\u4f8b\u5916\u306e\u578b\u3092\u8a18\u8ff0\u3057\u306a\u3051\u308c\u3070\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<span>catch<\/span>\u3057\u305f\u4f8b\u5916\u3068\u9055\u3046\u4f8b\u5916\u3092<span>throw<\/span>\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u767a\u751f\u3057\u305f\u4f8b\u5916\u3092\u6368\u3066\u3066\u3057\u307e\u3046\u3068\u672c\u5f53\u306b\u4f55\u304c\u767a\u751f\u3057\u305f\u304b\u304c\u547c\u3073\u51fa\u3057\u5143\u5074\u3067\u5206\u304b\u3089\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u65b0\u3057\u304f<span>throw<\/span>\u3059\u308b\u4f8b\u5916\u306b\u306f\u767a\u751f\u3057\u305f\u4f8b\u5916\u306e\u60c5\u5831\u3092\u6301\u305f\u305b\u308b\u3053\u3068\u304c\u666e\u901a\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\tthrow new IOException();\r\n} catch (IOException e) {\r\n\tSystem.out.println(\"IOException!!\"); \/\/ \u4f55\u304b\u306e\u51e6\u7406\u3092\u3084\u3063\u3066\u2026\r\n\tthrow new UncheckedIOException(e); \/\/ \u7570\u306a\u308b\u4f8b\u5916\u3092\u3001\u767a\u751f\u3057\u305f\u4f8b\u5916\u306e\u60c5\u5831\u3092\u6301\u305f\u305b\u3066\u751f\u6210\u3057\u3001throw\u3059\u308b\r\n}<\/pre>\n<h2><span id=\"Javatry-catch-3\">\uff13\uff0e\u3010Java\u3011try-catch\u6587\u3092\u4e0a\u624b\u306b\u6d3b\u7528\u3059\u308b\u305f\u3081\u306b<\/span><\/h2>\n<h3><span id=\"-catch-2\">\uff13-\uff11\uff0e\u4f8b\u5916\u3092<span>catch<\/span>\u3057\u3066\u4f55\u3082\u3057\u306a\u3044\u306e\u306f\u53b3\u7981<span>!<\/span><\/span><\/h3>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a<span>catch<\/span>\u3057\u305f\u4f8b\u5916\u306b\u5bfe\u3057\u3066\u5b9f\u8cea\u7684\u306b\u4f55\u3082\u884c\u3063\u3066\u3044\u306a\u3044\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u7d50\u69cb\u898b\u304b\u3051\u307e\u3059\u3002\u4ed5\u4e8b\u3067\u4f5c\u3089\u308c\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u3082\u6b8b\u5ff5\u306a\u304c\u3089\u898b\u304b\u3051\u307e\u3059\u3002\u3053\u308c\u306f\u300c\u4f8b\u5916\u3092\u63e1\u308a\u6f70\u3059\u300d\u3068\u8a00\u308f\u308c\u308b\u3053\u3068\u304c\u3042\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3001\u5927\u5909\u5371\u967a\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74061\r\n} catch (Exception e) {\r\n\t\/\/ catch\u306f\u3057\u3066\u3044\u308b\u304c\u3001\u4f55\u3082\u3057\u3066\u3044\u306a\u3044!!\r\n}<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74061\r\n} catch (Exception e) {\r\n\te.printStackTrace(); \/\/ catch\u3057\u305f\u4f8b\u5916\u3067printStackTrace\u3057\u3066\u3044\u308b\u3060\u3051!!\r\n}<\/pre>\n<p>\u306a\u305c\u5371\u967a\u306a\u306e\u304b\u3068\u8a00\u3046\u3068\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u8ab0\u306b\u3082\u5206\u304b\u3089\u306a\u3044\u304b\u3089\u3067\u3059\u3002\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u5f8c\u3082\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4f55\u4e8b\u3082\u306a\u304b\u3063\u305f\u304b\u306e\u3054\u3068\u304f\u5e73\u7136\u3068\u52d5\u304d\u7d9a\u3051\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u3002\u5f8c\u8005\u3082\u3001\u6a19\u6e96\u30a8\u30e9\u30fc\u51fa\u529b\u3092\u30ed\u30b0\u306b\u51fa\u529b\u3057\u3066\u3044\u308c\u3070\u307e\u3060\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u6368\u3066\u3066\u3057\u307e\u3063\u3066\u3044\u305f\u306a\u3089\u524d\u8005\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n<p>\u3053\u3046\u3044\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u307e\u304b\u308a\u901a\u3063\u3066\u3044\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001\u30a8\u30e9\u30fc\u5bfe\u5fdc\u304c\u5f8c\u624b\u306b\u56de\u3063\u305f\u308a\u3001\u554f\u984c\u304c\u81f4\u547d\u7684\u306a\u30ec\u30d9\u30eb\u306b\u306a\u3063\u3066\u521d\u3081\u3066\u3001\u5225\u306e\u7d4c\u8def\u3067\u554f\u984c\u304c\u767a\u899a\u3057\u305f\u308a\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u300c\u4f55\u304c\u8d77\u304d\u3066\u3044\u308b\u306e\u304b\u308f\u304b\u3089\u306a\u3044\u300d\u3068\u3044\u3046\u72b6\u6cc1\u306b\u306a\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u7d4c\u9a13\u304c\u6d45\u304b\u3063\u305f\u308a\u3001\u4ed5\u4e8b\u306e\u7d0d\u671f\u304c\u8fd1\u304b\u3063\u305f\u308a\u3059\u308b\u3068\u3001\u3068\u306b\u304b\u304f\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u3092\u306a\u304f\u3057\u3066\u65e9\u304f\u52d5\u304b\u3057\u305f\u3044\u4e00\u5fc3\u3067\u3053\u3046\u3044\u3046\u3053\u3068\u3092\u3059\u308b\u4eba\u304c\u3044\u307e\u3059\u3002\u3067\u3059\u304c\u3001\u6025\u304c\u3070\u56de\u308c\u3068\u8a00\u3046\u8a00\u8449\u3082\u3042\u308b\u3088\u3046\u306b\u3001\u4f8b\u5916\u3078\u306f\u304d\u3061\u3093\u3068\u5bfe\u51e6\u3059\u3079\u304d\u306a\u306e\u3067\u3059\u3002\u305d\u3046\u3057\u306a\u3044\u3068\u5f8c\u304b\u3089\u82e6\u52b4\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"-RuntimeExceptionErrorcatch\">\uff13-\uff12\uff0e\u3010\u4e2d\u7d1a\u8005\u5411\u3051\u3011RuntimeException\u3084Error\u306ecatch\u306f\u5fc5\u8981\u306a\u6642\u3060\u3051!<\/span><\/h3>\n<p>\u4f8b\u5916\u306e\u4e00\u7a2e\u3067\u3042\u308bRuntimeException\u3084Error\u306f\u3001\u5fc5\u8981\u6027\u304c\u306a\u3044\u9650\u308a\u306fcatch\u3057\u306a\u3044\u306e\u304c\u666e\u901a\u3067\u3059\u3002<\/p>\n<p>Java\u3067\u306e<span>Throwable<\/span>\u95a2\u9023\u306e\u30af\u30e9\u30b9\u968e\u5c64\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u6700\u4e0a\u4f4d\u306b\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<span>Throwable<\/span>\u304c\u3042\u308a\u3001\u305d\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u306b<span>Exception<\/span>\u3068<span>Error<\/span>\u3001<span>Exception<\/span>\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3068\u3057\u3066<span>RuntimeException<\/span>\u304c\u3042\u308a\u307e\u3059\u3002\u5b9f\u969b\u306e\u4f8b\u5916\u306f\u3001\u3053\u308c\u3089\u306e\u3069\u308c\u304b\u304b\u3089\u7d99\u627f\u3057\u3066\u4f5c\u3089\u308c\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>Throwable \u2192 \u5168\u3066\u306e\u4f8b\u5916\u30fb\u30a8\u30e9\u30fc\u306e\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9<\/p>\n<p>\u3000\u3000\u2517Exception \u2192 catch\u3055\u308c\u308b\u3079\u304d\u4f8b\u5916\u306e\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9<\/p>\n<p>\u3000\u3000\u3000\u3000\u3000\u3000\u2517RuntimeException \u2192 \u975e\u30c1\u30a7\u30c3\u30af\u4f8b\u5916\u306e\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9<\/p>\n<p>\u3000\u3000\u2517Error \u2192 \u901a\u5e38\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f<span>catch<\/span>\u3059\u3079\u304d\u3067\u306a\u3044\u91cd\u5927\u306a\u30a8\u30e9\u30fc<\/p>\n<\/blockquote>\n<p>\u3053\u306e\u4e2d\u3067\u3001\u30e1\u30bd\u30c3\u30c9\u306e<span>throws<\/span>\u7bc0\u306b\u3042\u308b\u5834\u5408\u306b\u5bfe\u51e6\u304c\u5fc5\u8981\u306a\u306e\u306f<span>Throwable<\/span>\u3068<span>Exception<\/span>\u306e\u4e8c\u7a2e\u985e\u3067\u3059\u3002\u9006\u306b\u8a00\u3046\u3068\u3001<span>RuntimeException<\/span>\u3068<span>Error<\/span>\u306f<span>throws<\/span>\u7bc0\u306b\u660e\u793a\u7684\u306b\u66f8\u3044\u3066\u3042\u3063\u3066\u3082\u3001<span>try-catch<\/span>\u306e\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<span>RuntimeException<\/span>\u3084<span>Error<\/span>\u306f\u3069\u3093\u306a\u3082\u306e\u304c\u5b9f\u969b\u306b<span>throw<\/span>\u3055\u308c\u308b\u304b\u306f\u5206\u304b\u3089\u306a\u3044\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">public class TryCatchThrowsSample {\r\n\t\/\/ \u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306b\u306fthrows\u7bc0\u306f\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u4e2d\u3067\u4f8b\u5916\u3078\u5bfe\u51e6\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\r\n\tvoid throwsTest() {\r\n\t\tthrowsThrowable(); \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! Throwable\u3078\u306f\u4f55\u304b\u3057\u3089\u5bfe\u51e6\u304c\u5fc5\u8981\r\n\t\tthrowsException(); \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc!! Exception\u3078\u306f\u4f55\u304b\u3057\u3089\u5bfe\u51e6\u304c\u5fc5\u8981\r\n\t\tthrowsRuntimeException(); \/\/ RuntimeException\u306f\u5bfe\u51e6\u3057\u306a\u304f\u3066\u3082\u3044\u3044\r\n\t\tthrowsError(); \/\/ Error\u306f\u5bfe\u51e6\u3057\u306a\u304f\u3066\u3082\u3044\u3044\r\n\t}\r\n\r\n\tvoid throwsThrowable() throws Throwable {\r\n\t\tthrow new Throwable() {};\r\n\t}\r\n\r\n\tvoid throwsException() throws Exception {\r\n\t\tthrow new Exception();\r\n\t}\r\n\r\n\tvoid throwsRuntimeException() throws RuntimeException {\r\n\t\tthrow new RuntimeException();\r\n\t}\r\n\r\n\tvoid throwsError() throws Error {\r\n\t\tthrow new Error();\r\n\t}\r\n}<\/pre>\n<p>Java\u3067\u306e\u6c7a\u3081\u4e8b\u3068\u3057\u3066\u3001RuntimeException\u3084Error\u306f\u5bfe\u51e6\u4e0d\u80fd\u306a\u30a8\u30e9\u30fc\u3092\u8868\u73fe\u3057\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u74b0\u5883\u4e0d\u5099\u3084\u30d7\u30ed\u30b0\u30e9\u30e0\u30df\u30b9\u306a\u3069\u304c\u539f\u56e0\u3067\u3042\u308a\u3001\u767a\u751f\u3057\u3066\u3082\u660e\u793a\u7684\u306a\u30ea\u30ab\u30d0\u30ea\u51e6\u7406\u3092\u3059\u308b\u3079\u304d\u3067\u306f\u306a\u3044\u30a8\u30e9\u30fc\u3001\u3068\u3044\u3046\u6271\u3044\u3067\u3059\u3002\u304d\u3061\u3093\u3068\u74b0\u5883\u69cb\u7bc9\u3084\u30c6\u30b9\u30c8\u3092\u884c\u3063\u3066\u3044\u308c\u3070\u3001\u5b9f\u904b\u7528\u4e0a\u3067\u306f\u767a\u751f\u3057\u306a\u3044\u306f\u305a\u306e\u3082\u306e\u3060\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u3067\u3059\u306e\u3067\u3001<span>RuntimeException<\/span>\u3084<span>Error<\/span>\u306b\u5bfe\u3057\u3066\u3001<span>try-catch<\/span>\u6587\u3067\u660e\u793a\u7684\u306b\u88dc\u8db3\u3057\u3066\u51e6\u7406\u3092\u3059\u3079\u304d\u30b1\u30fc\u30b9\u306f\u5c11\u306a\u3044\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u3002\u305f\u3060\u3057\u3001\u3044\u304b\u306a\u308b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3082\u305a\u3063\u3068\u52d5\u304d\u7d9a\u3051\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u7a2e\u985e\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306a\u3089<span>catch<\/span>\u304c\u5fc5\u8981\u3067\u3059<span>(WEB<\/span>\u30b5\u30fc\u30d0\u306a\u3069\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306b\u5e38\u99d0\u3059\u308b\u7a2e\u985e\u306e\u3082\u306e\u3067\u3059<span>)<\/span>\u3002<\/p>\n<p>\u4e00\u65b9\u3001<span>Exception<\/span>\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u30df\u30b9\u7b49\u3067\u306f\u306a\u304f\u3001\u901a\u5e38\u306e\u51e6\u7406\u4e0a\u3067\u767a\u751f\u3057\u3048\u3066\u3001\u4f55\u304b\u3057\u3089\u306e\u30ea\u30ab\u30d0\u30ea\u51e6\u7406\u3092\u547c\u3073\u51fa\u3057\u5074\u304c\u884c\u3046\u3079\u304d\u30a8\u30e9\u30fc\u3092\u8868\u73fe\u3059\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002\u3067\u3059\u304b\u3089\u3001<span>Exception<\/span>\u306f\u5bfe\u51e6\u304c\u69cb\u6587\u4e0a\u3082\u5fc5\u9808\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u767a\u751f\u3057\u3046\u308b\u4f8b\u5916\u3078\u306e\u5bfe\u5fdc\u3092\u547c\u3073\u51fa\u3057\u5074\u3078\u5f37\u5236\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u30e1\u30bd\u30c3\u30c9\u306e<span>Javadoc<\/span>\u3084<span>throws<\/span>\u7bc0\u3067<span>RuntimeException<\/span>\u3084<span>Error<\/span>\u304c\u767a\u751f\u3059\u308b\u3068\u660e\u793a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u305d\u3046\u3044\u3046\u3053\u3068\u304c\u8d77\u3053\u308a\u5f97\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u7406\u89e3\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\u5b9f\u969b\u306b\u767a\u751f\u3057\u305f\u5834\u5408\u306e\u5bfe\u51e6\u304c\u3084\u308a\u3084\u3059\u304f\u306a\u308b\u304b\u3089\u3067\u3059\u3057\u3001\u305d\u3046\u3044\u3046\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u306a\u3044\u3088\u3046\u306a\u4e88\u9632\u63aa\u7f6e\u3082\u3067\u304d\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<h3><span id=\"-try\">\uff13-\uff13\uff0e\u3010\u4e2d\u7d1a\u8005\u5411\u3051\u3011<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u306e\u7bc4\u56f2\u306f\u306a\u308b\u3079\u304f\u72ed\u304f\u3057\u3088\u3046<span>!<\/span><\/span><\/h3>\n<h4>\uff13-\uff13-\uff11\uff0e\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u30fb\u3057\u306a\u3044\u51e6\u7406\u304c\u6df7\u5728\u3059\u308b\u5834\u5408<\/h4>\n<p>\u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u7406\u304c\u30d7\u30ed\u30b0\u30e9\u30e0\u4e2d\u306b\u8907\u6570\u3042\u308a\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u306a\u3044\u51e6\u7406\u3068\u6df7\u5728\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u3069\u3061\u3089\u304c\u826f\u3044<span>try-catch<\/span>\u6587\u306e\u66f8\u304d\u65b9\u3067\u3057\u3087\u3046\u304b\u3002\u7406\u7531\u3082\u542b\u3081\u3066\u3001\u5c11\u3057\u8003\u3048\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74061\r\n\t\/\/ \u4f8b\u5916\u306f\u767a\u751f\u3057\u306a\u3044\u51e6\u7406\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74062\r\n\t\/\/ \u4f8b\u5916\u306f\u767a\u751f\u3057\u306a\u3044\u51e6\u7406\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74063\r\n} catch (SomeException1 e) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u74061\r\n} catch (SomeException2 e) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u74062\r\n} catch (SomeException3 e) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u74063\r\n}<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74061\r\n} catch (SomeException1 e) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u7406\r\n}\r\n\r\n\/\/ \u4f8b\u5916\u306f\u767a\u751f\u3057\u306a\u3044\u51e6\u7406\r\n\r\ntry {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74062\r\n} catch (SomeException2 e) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u7406\r\n}\r\n\r\n\/\/ \u4f8b\u5916\u306f\u767a\u751f\u3057\u306a\u3044\u51e6\u7406\r\n\r\ntry {\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u51e6\u74063\r\n} catch (SomeException3 e) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u7406\r\n}<\/pre>\n<p>\u3069\u3046\u3059\u3079\u304d\u304b\u306f\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306b\u3088\u308a\u610f\u898b\u306f\u5206\u304b\u308c\u307e\u3059\u304c\u3001\u4e00\u822c\u7684\u306b\u306f\u300c<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u306e\u30b9\u30b3\u30fc\u30d7\u306f\u306a\u308b\u3079\u304f\u5c0f\u3055\u304f\u3059\u3079\u304d\u300d\u3068\u8a00\u308f\u308c\u307e\u3059\u3002\u5b9f\u969b\u306f\u524d\u8005\u3068\u5f8c\u8005\u306e\u6298\u8877\u6848\u7684\u306a\u5e83\u3055\u3068\u306a\u308b\u3053\u3068\u304c\u591a\u304f\u3001\u305d\u306e\u4e0a\u3067\u5f8c\u8005\u306b\u8fd1\u3044\u30b9\u30bf\u30a4\u30eb\u304c\u826f\u3044\u3068\u3055\u308c\u3066\u3044\u308b\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>try\u30d6\u30ed\u30c3\u30af\u306e\u7bc4\u56f2\u304c\u5e83\u3059\u304e\u308b\u3068\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u306a\u3044\u3068\u3053\u308d\u3082\u542b\u307e\u308c\u3066\u3057\u307e\u3044\u3001\u3069\u306e\u51e6\u7406\u306b\u5bfe\u3059\u308b\u4f8b\u5916\u51e6\u7406\u306a\u306e\u304b\u304c\u4e0d\u660e\u77ad\u306b\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3001\u4e00\u3064\u4e00\u3064\u306e\u51e6\u7406\u306b\u3044\u3061\u3044\u3061\u500b\u5225\u306e<span>try-catch<\/span>\u6587\u3092\u4f7f\u3063\u3066\u306f\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u3068\u3066\u3082\u9577\u304f\u306a\u308a\u307e\u3059\u3057\u3001\u898b\u901a\u3057\u3082\u975e\u5e38\u306b\u60aa\u304f\u306a\u308a\u307e\u3059\u3002\u4f55\u4e8b\u3082\u6975\u7aef\u3059\u304e\u3066\u306f\u3044\u3051\u306a\u3044\u306e\u3067\u3059\u306d\u3002<\/p>\n<p>\u3067\u3059\u306e\u3067\u3001\u3042\u3044\u307e\u3044\u306a\u8a00\u3044\u65b9\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u73fe\u5b9f\u7684\u306b\u306f\u51e6\u7406\u306e\u307e\u3068\u307e\u308a\u304c\u826f\u3044\u5358\u4f4d\u3060\u3063\u305f\u308a\u3001\u3053\u308c\u3089\u306e\u51e6\u7406\u306f\u4e00\u584a\u306b\u3057\u3066\u51e6\u7406\u7d50\u679c\u3092\u4fdd\u8a3c\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044<span>\u2026<\/span>\u3068\u3044\u3046\u3088\u3046\u306a\u5358\u4f4d\u3068\u3059\u308b\u3068\u3001\u898b\u305f\u76ee\u4e0a\u3082\u51e6\u7406\u4e0a\u3082\u3001\u826f\u3044\u30d0\u30e9\u30f3\u30b9\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<h4>\uff13-\uff13-\uff12\uff0e\u30eb\u30fc\u30d7\u306e\u4e2d\u3067\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u5834\u5408<\/h4>\n<p>\u307e\u305f\u3001\u4ee5\u4e0b\u306e\u30eb\u30fc\u30d7\u51e6\u7406\u5185\u3067\u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u5834\u5408\u3078\u306e\u5bfe\u5fdc\u306f\u3001\u3069\u3061\u3089\u304c\u3088\u308a\u826f\u3044<span>try-catch<\/span>\u6587\u306e\u66f8\u304d\u65b9\u3060\u3068\u601d\u308f\u308c\u307e\u3059\u304b<span>?<\/span><\/p>\n<pre class=\"prettyprint lang:default decode:true\">try {\r\n\tfor (int = 0; i &lt; XXXX; i++) {\r\n\t\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u4f55\u304b\u306e\u51e6\u7406\r\n\t}\r\n} catch (Exception e) {\r\n\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u7406\r\n}<\/pre>\n<pre class=\"prettyprint lang:default decode:true\">for (int = 0; i &lt; XXXX; i++) {\r\n\ttry {\r\n\t\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u4f55\u304b\u306e\u51e6\u7406\r\n\t} catch (Exception e) {\r\n\t\t\/\/ \u4f8b\u5916\u767a\u751f\u6642\u306e\u30d5\u30a9\u30ed\u30fc\u51e6\u7406\r\n\t}\r\n}<\/pre>\n<p>\u3053\u306e\u5834\u5408\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u4ed5\u69d8\u306b\u3088\u308a\u307e\u3059\u3002\u4f8b\u5916\u767a\u751f\u6642\u306b<span>for<\/span>\u6587\u81ea\u4f53\u3092\u4e2d\u65ad\u3055\u305b\u308b\u306e\u304b\u3001\u305d\u308c\u3068\u3082\u51e6\u7406\u3092\u7d99\u7d9a\u3059\u3079\u304d\u306a\u306e\u304b\u306e\u4ed5\u69d8\u304c\u660e\u78ba\u306b\u306a\u3063\u3066\u3044\u306a\u3051\u308c\u3070\u3001\u3069\u3061\u3089\u304c\u826f\u3044\u304b\u306e\u5224\u65ad\u306f\u3067\u304d\u306a\u3044\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>for\u6587\u3092\u4e2d\u65ad\u3055\u305b\u308b\u306a\u3089\u524d\u8005\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u3082\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u6642\u306b\u306f<span>for<\/span>\u6587\u304c\u7d42\u4e86\u3059\u308b\u3053\u3068\u304c\u660e\u78ba\u3001\u304b\u3064\u69cb\u6587\u30ec\u30d9\u30eb\u3067\u78ba\u5b9f\u3060\u304b\u3089\u3067\u3059\u3002\u5f8c\u8005\u306e\u30b9\u30bf\u30a4\u30eb\u3067\u3084\u308b\u306a\u3089<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u5185\u3067<span>break<\/span>\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u610f\u56f3\u304c\u5c11\u3005\u4f1d\u308f\u308a\u3065\u3089\u3044\u3067\u3057\u3087\u3046\u304b\u3002\u305d\u308c\u306b<span>break<\/span>\u3092\u66f8\u304d\u5fd8\u308c\u305f\u3089\u305d\u306e\u307e\u307e\u52d5\u3044\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u5f8c\u8005\u306f\u3001\u4f8b\u5916\u767a\u751f\u6642\u306b\u306f\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3001\u51e6\u7406\u81ea\u4f53\u306f\u7d99\u7d9a\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u30b1\u30fc\u30b9\u306b\u9069\u3057\u3066\u3044\u308b\u3067\u3057\u3087\u3046\u304b\u3002\u524d\u8005\u306e\u30b9\u30bf\u30a4\u30eb\u3067\u3084\u308b\u306a\u3089\u3001\u518d\u5ea6<span>for<\/span>\u6587\u3092\u7d9a\u304d\u304b\u3089\u5b9f\u884c\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u304c\u3001\u3055\u3059\u304c\u306b\u305d\u306e\u3088\u3046\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308a\u305f\u3044\u3068\u306f\u601d\u3048\u307e\u305b\u3093\u3057\u3001\u610f\u5473\u306e\u5206\u304b\u308a\u3065\u3089\u3044\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<span>for<\/span>\u6587\u306a\u3069\u306e\u4e2d\u3067<span>try-catch<\/span>\u3092\u7e70\u308a\u8fd4\u3059\u306e\u306f\u3001\u5b9f\u884c\u901f\u5ea6\u306b\u5168\u304f\u5f71\u97ff\u304c\u51fa\u306a\u3044\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3067\u3082\u3001\u305d\u308c\u304c\u76ee\u306b\u898b\u3048\u308b\u5f62\u3067\u73fe\u308c\u308b\u3053\u3068\u306f\u307b\u307c\u306a\u3044\u3067\u3057\u3087\u3046\u3002\u3067\u3059\u304b\u3089\u3001\u305d\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u4e2d\u3067\u4f8b\u5916\u767a\u751f\u6642\u306b\u306f\u3069\u3046\u52d5\u304f\u3079\u304d\u304b<span>\u2026<\/span>\u3068\u3044\u3046\u4ed5\u69d8\u3092\u307e\u305a\u660e\u78ba\u306b\u3057\u3066\u3001\u305d\u308c\u306b\u5fdc\u3058\u3066\u4f7f\u3044\u5206\u3051\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2><span id=\"i-2\">\uff14\uff0e\u307e\u3068\u3081<\/span><\/h2>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f<span>try-catch<\/span>\u5206\u306e\u57fa\u672c\u3092\u304a\u4f1d\u3048\u3057\u307e\u3057\u305f\u3002<span>try<\/span>\u30d6\u30ed\u30c3\u30af\u3067\u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u90e8\u5206\u3092\u6307\u5b9a\u3057\u3001<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u3067\u767a\u751f\u3057\u305f\u4f8b\u5916\u3078\u306e\u51e6\u7406\u3092\u884c\u3046\u306e\u304c\u57fa\u672c\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u5916\u306e<span>catch<\/span>\u306e\u4ed5\u65b9\u306f\u3001\u904e\u53bb\u306e\u69cb\u6587\u3067\u306f<span>1<\/span>\u3064\u306e<span>catch<\/span>\u30d6\u30ed\u30c3\u30af\u306b<span>1<\/span>\u3064\u306e\u4f8b\u5916\u3057\u304b\u6307\u5b9a\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u4eca\u3067\u306f\u8907\u6570\u306e\u4f8b\u5916\u3092<span>catch<\/span>\u3067\u304d\u308b\u30de\u30eb\u30c1\u30ad\u30e3\u30c3\u30c1\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u30af\u30e9\u30b9\u306e\u7d99\u627f\u95a2\u4fc2\u306b\u6c17\u3092\u4ed8\u3051\u305f\u4e0a\u3067\u3001\u7a4d\u6975\u7684\u306b\u6d3b\u7528\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308b\u4e0a\u3067\u306f\u3001\u30a8\u30e9\u30fc\u51e6\u7406\u306f\u7d76\u5bfe\u306b\u6b20\u304b\u305b\u307e\u305b\u3093\u3002\u305d\u3057\u3066\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u6b63\u5e38\u7cfb\u306e\u51e6\u7406\u3088\u308a\u3082\u30a8\u30e9\u30fc\u7cfb\u306e\u51e6\u7406\u306e\u5206\u91cf\u306e\u65b9\u304c\u591a\u3044\u3082\u306e\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u304a\u4f1d\u3048\u3057\u305f\u3053\u3068\u3092\u6d3b\u7528\u3057\u3066\u3001\u30a8\u30e9\u30fc\u51e6\u7406\u306b\u3082\u6c17\u304c\u914d\u3089\u308c\u305f\u826f\u3044\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u306etry-catch\u6587\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u4e2d\u3067\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u304b\u8a66\u3057\u3066(try)\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u3089\u6355\u307e\u3048\u3066(catch)\u3001\u4f55\u304b\u3057\u3089\u306e\u51e6\u7406\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306b\u4f7f\u3044\u307e\u3059\u3002 \u3053\u306e\u8a18\u4e8b\u3067\u306ftry\u306e\u7528\u9014\u306e\u4e00\u3064\u300c\u4f8b\u5916\u51e6\u7406\u306etry-cat [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":804,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/884"}],"collection":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/comments?post=884"}],"version-history":[{"count":8,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/884\/revisions"}],"predecessor-version":[{"id":5691,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/884\/revisions\/5691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media\/804"}],"wp:attachment":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media?parent=884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/categories?post=884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}