to{}catch{}
try{}catch{}的流传输
try { fis = new FileInputStream("file-APP\\fos.txt"); fos = new FileOutputStream("fos.txt"); int a ; while ((a= fis.read())!= -1){ fos.write(a); } System.out.println(a); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fis != null) { fis.close(); } } catch (IOException e) { e.printStackTrace(); } }
try(){}catch{}的流传输 省略close()
try{}catch{}finally{}
finalize()方法*
Objects的equals()方法*
抛异常
自己怎么创建异常 抛异常
创建异常类 重载所有构造方法
文章来源:https://www.toymoban.com/news/detail-681445.html
class StudentAgeIllegalException extends Exception { public StudentAgeIllegalException() { } public StudentAgeIllegalException(String message) { super(message); } public StudentAgeIllegalException(String message, Throwable cause) { super(message, cause); } public StudentAgeIllegalException(Throwable cause) { super(cause); } public StudentAgeIllegalException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } }
创建异常类对象
抛出异常
文章来源地址https://www.toymoban.com/news/detail-681445.html
到了这里,关于day28 异常的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!