zoukankan      html  css  js  c++  java
  • java 学习第十九天2020/7/24

    一.

    throws子句方法的基本形式

    【修饰符】 返回类型 方法名(参数1.参数2.....) throws  throws 立场列表{}

    public class ThrowsDemo
    {
         public static viod main(String[] args)throws Exception{
         int x=5;
         int y=x/0;
    System.out.println(y);
         }
    }
    

     throws子句中可以同时致命多个异常,

    对异常不进行处理只是将异常抛弃;

    throw   手动抛弃异常

    被抛弃必须是Throwable或其子类的事例   throw 异常名;

    public class ThrowsDemo
    {
         public static viod main(String[] args){
         try{
             System.out.println{"正在运行"};
             throw new IOException("异常");
         }catch(IOException e)
         {
             e.printStackTrace();
         }
         }
    }
    

    若要创建自己的异常类型,只要定义Exception的一个子类就可以

    二.Throwable或其子类

    三.日志信息

  • 相关阅读:
    Angular2+学习第1篇 简介
    JS:ES5数组基本操作
    git常用操作命令
    URL-Routing
    uid-datepicker
    元素隐藏 css
    Angular2+学习第2篇 cli 环境搭建过程
    DRF 07
    DRF小练习 04
    DRF小练习 02
  • 原文地址:https://www.cnblogs.com/qiangini/p/13374839.html
Copyright © 2011-2022 走看看