{"id":614,"date":"2019-02-17T14:07:25","date_gmt":"2019-02-17T06:07:25","guid":{"rendered":"http:\/\/www.eait.co\/?p=614"},"modified":"2019-04-05T12:31:17","modified_gmt":"2019-04-05T04:31:17","slug":"java-%e6%8c%87%e5%ae%9a%e6%96%b9%e6%b3%95%e6%8a%9b%e5%87%ba%e5%bc%82%e5%b8%b8","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=614","title":{"rendered":"java\u2014\u2014\u6307\u5b9a\u65b9\u6cd5\u629b\u51fa\u5f02\u5e38"},"content":{"rendered":"<pre>\/**\r\n * Created by xabcd on 2019\/2\/17.\r\n *\/\r\npublic class java_waythrow\r\n{\r\n    static class throwss\r\n\r\n    {\r\n        void add( int a, int b)throws Exception\r\n        {\r\n            int c;\r\n            c = a \/ b;\r\n            System.out.println(a \/ b);\r\n        }\r\n    }\r\n    public static void main(String args[])\r\n    {\r\n        throwss t = new throwss();\r\n        try {\r\n            t.add(4,0);\r\n        }\r\n        catch (Exception e)\r\n        {\r\n            System.out.println(e);\r\n        }\r\n    }\r\n}\r\n\r\n\r\n\r\n\r\n<\/pre>\n<p>\u4ece \u7f16\u8bd1 \u7ed3\u679c \u4e2d \u53ef\u4ee5 \u770b\u5230\uff0c \u5982\u679c \u5728 \u7c7b \u7684 \u65b9\u6cd5 \u4e2d\u7528 throws \u629b\u51fa \u4e00\u4e2a \u5f02\u5e38\uff0c \u90a3\u4e48 \u5728\u8c03 \u7528 \u5b83\u7684 \u5730\u65b9 \u5c31\u5fc5\u987b \u660e\u786e \u5730 \u7528 try- catch \u6765 \u6355\u6349\u3002 \u63d0 \u3000 \u793a\uff1a \u5728 TestException_ 5 \u7a0b\u5e8f \u4e4b\u4e2d\uff0c \u5982\u679c \u5728 main() \u65b9\u6cd5 \u7684 \u540e\u9762 \u518d\u7528 throws Exception \u58f0\u660e \u7684 \u8bdd\uff0c \u90a3\u4e48 \u7a0b\u5e8f \u4e5f\u662f \u4f9d\u7136 \u53ef\u4ee5 \u7f16\u8bd1 \u901a\u8fc7 \u7684\u3002 \u4e5f\u5c31\u662f\u8bf4 \u5728 \u8c03\u7528 throws \u629b\u51fa \u5f02\u5e38 \u7684 \u65b9\u6cd5 \u65f6\uff0c \u53ef\u4ee5 \u5c06\u6b64 \u5f02\u5e38 \u5728 \u65b9\u6cd5 \u4e2d \u518d\u5411 \u4e0a \u4f20\u9012\uff0c \u800c main() \u65b9\u6cd5 \u662f \u6574\u4e2a \u7a0b\u5e8f \u7684 \u8d77\u70b9\uff0c \u6240\u4ee5 \u5728 main() \u65b9\u6cd5 \u5904 \u5982\u679c \u518d\u7528 throws \u629b\u51fa \u5f02\u5e38\uff0c \u5219 \u6b64 \u5f02\u5e38 \u5c31 \u5c06 \u4ea4\u7531 JVM \u8fdb\u884c \u5904\u7406\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/** * Created by xabcd on 2019\/2\/17. *\/ public class ja [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,24],"tags":[],"class_list":["post-614","post","type-post","status-publish","format-standard","hentry","category-java","category-base_code"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=614"}],"version-history":[{"count":1,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/614\/revisions"}],"predecessor-version":[{"id":615,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/614\/revisions\/615"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}