一.
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或其子类
三.日志信息