

{"id":98,"date":"2021-08-31T11:41:01","date_gmt":"2021-08-31T03:41:01","guid":{"rendered":"https:\/\/www.52dixiaowo.com\/javav2\/?p=98"},"modified":"2021-08-31T19:09:28","modified_gmt":"2021-08-31T11:09:28","slug":"java%e5%bc%82%e5%b8%b8%e6%b5%8b%e8%af%95%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.52dixiaowo.com\/javav2\/post-98.html","title":{"rendered":"java\u5f02\u5e38\u6d4b\u8bd5\u9898"},"content":{"rendered":"\n<p>1.throw\u548cthrows\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/p>\n\n\n\n<p>2.\u53d1\u751f\u5f02\u5e38\u540e\uff0c\u5982\u4f55\u8ddf\u8e2a\u5806\u6808\u5f02\u5e38\u4fe1\u606f\uff1f<\/p>\n\n\n\n<p>3.\u4e00\u4e2a\u65b9\u6cd5\u58f0\u660e\u629b\u51fa\u5f02\u5e38\uff0c\u8c03\u7528\u8005\u5982\u679c\u4e0d\u8fdb\u884c\u4efb\u4f55\u5904\u7406\uff0c\u7a0b\u5e8f\u80fd\u5426\u8fd0\u884c\uff1f<\/p>\n\n\n\n<p>4.\u5728\u4e00\u4e2a\u65b9\u6cd5\u4e2d\uff0c\u80fd\u5426\u65e2throw\u629b\u51fa\u5f02\u5e38\uff0c\u53c8\u628a\u5b83\u6355\u83b7\uff1f\u5982\u679c\u53ef\u4ee5\uff0c\u65b9\u6cd5\u8c03\u7528\u8005\u662f\u5426\u9700\u8981\u5904\u7406\u8be5\u5f02\u5e38\uff1f\u5982\u679c\u4e0d\u53ef\u4ee5\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u53ef\u4ee5\uff1f<\/p>\n\n\n\n<p>5.\u4ee5\u4e0b\u4ee3\u7801\u80fd\u5426\u8fd0\u884c\uff1f\u5982\u679c\u9519\u4e86\uff0c\u54ea\u884c\u9519\u4e86\uff1f\u4e3a\u4ec0\u4e48\u9519\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/import java.io.*;\npublic static void main(String[] args){\n    try(FileWriter fw = new FileWriter(\"D:\\\\a.txt\",true);){\n        for(int i=0;i&lt;10;i++){\n        fw.write(\"abc\"+i+\"\\r\\n\");\n        }\n    }catch(IOException e){\n        System.out.println(e);\n    }finally{\n        fw.close();\n    }\n}<\/pre>\n\n\n\n<p>6.\u4ee5\u4e0bcheckPassWord\u65b9\u6cd5\u4ee3\u7801\u662f\u5426\u9519\u8bef\uff1f\u5982\u679c\u9519\u4e86\uff0c\u54ea\u884c\u9519\u4e86\uff1f\u4e3a\u4ec0\u4e48\u9519\uff1f\u5982\u679c\u6b63\u786e\uff0c\u8fd0\u884c\u7ed3\u679c\u662f\u4ec0\u4e48\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public static void main(String[] args){\n\n    String pwd = \"12345678\";\n    System.<em>out<\/em>.println(\"\u5bc6\u7801\"+pwd+\"\u662f\u5426\u7b26\u5408\u8981\u6c42\uff1f\"+<em>checkPassWord<\/em>(pwd));\n}\n\npublic static boolean checkPassWord(String pwd){\n\/\/ \u68c0\u6d4bpwd\u5b57\u7b26\u4e32\uff0c\u81f3\u5c11\u5305\u542b8\u4e2a\u5b57\u7b26\uff0c\u5982\u679c\u4e0d\u7b26\u5408\u5219\u629b\u51fa\u4e00\u4e2ajava.lang.NumberFormatException\n    if(pwd.length()&lt;8){\n        throw new NumberFormatException(\"\u5bc6\u7801\u9519\u8bef\");\n        return false;\n    }\n    else {\n        return true;\n    }\n}<\/pre>\n\n\n\n<p>7.\u4ee5\u4e0b\u4ee3\u7801\u6267\u884c\u7ed3\u679c\u662f\u4ec0\u4e48\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public static void main(String&#91;] args){\n    int&#91;] a = new int&#91;10];\n    try{\n        System.out.println(a&#91;10]);\n        System.out.println(a&#91;1]);\n    }catch (Exception e){\n        System.out.println(1);\n    }\n    try{\n        System.out.println(a&#91;10]);\n    }catch (Exception e){\n        System.out.println(2);\n    }\n    System.out.println(a&#91;1]);\n}<\/code><\/pre>\n\n\n\n<p>8.\u5982\u679c\u5728main\u4e2d\u58f0\u660e\u629b\u51fa\u5f02\u5e38\uff0c\u4e00\u65e6\u53d1\u751f\u5f02\u5e38\uff0cmain\u4f1a\u5c06\u5f02\u5e38\u629b\u7ed9\u8c01\uff1f\u7a0b\u5e8f\u662f\u5426\u4f1a\u88ab\u7ec8\u6b62\uff1f\u8fd9\u8bf4\u660e\u4e86\u4ec0\u4e48\uff1f<\/p>\n\n\n\n<p>9.\u5728\u4f7f\u7528try-catch\u65f6\uff0c\u80fd\u5426\u6355\u83b7\u7f16\u8bd1\u671f\u5f02\u5e38?\u80fd\u5426\u6355\u83b7\u8fd0\u884c\u671f\u5f02\u5e38?\u80fd\u5426\u6355\u83b7Error?\u80fd\u5426\u6355\u83b7Throwable?\u80fd\u5426\u6355\u83b7Object?<\/p>\n\n\n\n<p>10.\u65b9\u6cd5\u8986\u76d6\u540e\uff0c\u80fd\u5426\u629b\u51fa\u629b\u51fa(throw)\u66f4\u5927\u7684\u5f02\u5e38?\u80fd\u5426\u58f0\u660e\u629b\u51fa(throws)\u66f4\u5927\u7684\u5f02\u5e38?<\/p>\n\n\n\n<p>11.\u8c03\u7528\u65b9\u6cd5\u65f6\uff0c\u4e0d\u6355\u83b7\u5f02\u5e38\uff0c\u80fd\u5426\u629b\u51fa(throw)\u66f4\u5c0f\u7684\u5f02\u5e38?\u80fd\u5426\u58f0\u660e\u629b\u51fa(throws)\u66f4\u5c0f\u7684\u5f02\u5e38?<\/p>\n\n\n\n<p>12.\u65b9\u6cd5\u4e2d\u629b\u51fa(throw)\u5f02\u5e38\u65f6\uff0c\u672c\u8eab\u4e5f\u4e0d\u6355\u83b7\uff0c\u662f\u5426\u9700\u8981\u58f0\u660e\u629b\u51fa(throws)\u5f02\u5e38?<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.throw\u548cthrows\u6709\u4ec0\u4e48\u533a\u522b\uff1f 2.\u53d1\u751f\u5f02\u5e38\u540e\uff0c\u5982\u4f55\u8ddf\u8e2a\u5806\u6808\u5f02\u5e38\u4fe1\u606f\uff1f 3.\u4e00\u4e2a\u65b9\u6cd5\u58f0\u660e\u629b\u51fa\u5f02\u5e38\uff0c\u8c03&hellip; <a href=\"https:\/\/www.52dixiaowo.com\/javav2\/post-98.html\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">java\u5f02\u5e38\u6d4b\u8bd5\u9898<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/posts\/98"}],"collection":[{"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":0,"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52dixiaowo.com\/javav2\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}