摘要: 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免的。 比如说,你的代码少了一个分号,那么运行出来结果是提示是错误 java.lang.Error;如果你用System.out.println(11/0),那么你是因为你用0做了除数,会抛出 java.lang.Arithm 阅读全文
posted @ 2019-11-03 22:34 明月照我还 阅读(151) 评论(0) 推荐(0) 编辑
摘要: package we; /** * 自定义的异常类 * @author JinXuLiang * */ class MyException extends Exception { public MyException(String Message) { super(Message); } publi 阅读全文
posted @ 2019-11-03 21:47 明月照我还 阅读(274) 评论(0) 推荐(0) 编辑
摘要: package we; import java.io.*; public class OverrideThrows { public void test()throws IOException { FileInputStream fis = new FileInputStream("a.txt"); 阅读全文
posted @ 2019-11-03 21:45 明月照我还 阅读(159) 评论(0) 推荐(0) 编辑
摘要: package we; import java.io.IOException; public class ThrowMultiExceptionsDemo { public static void main(String[] args) { try { throwsTest(); } catch(I 阅读全文
posted @ 2019-11-03 21:44 明月照我还 阅读(176) 评论(0) 推荐(0) 编辑
摘要: package we; public class PrintExceptionStack { public static void main( String args[] ) { try { method1(); } catch ( Exception e ) { System.err.printl 阅读全文
posted @ 2019-11-03 21:43 明月照我还 阅读(140) 评论(0) 推荐(0) 编辑
摘要: package we; public class SystemExitAndFinally { public static void main(String[] args) { try{ System.out.println("in main"); throw new Exception("Exce 阅读全文
posted @ 2019-11-03 21:41 明月照我还 阅读(161) 评论(0) 推荐(0) 编辑
摘要: package we; public class EmbededFinally { public static void main(String args[]) { int result; try { System.out.println("in Level 1"); try { System.ou 阅读全文
posted @ 2019-11-03 21:39 明月照我还 阅读(138) 评论(0) 推荐(0) 编辑