java异常

//函数抛出异常 ———— 注意捕捉异常时 finally 的使用:
//1、关闭打开的文件
//2、删除临时的文件
//
void m(int i) throws ArithmeticException
{
  
if(i == o)
  {
    
throw new ArithmeticException("除数为0")
  }
}
void f() throws FileNotFoundException , IOException
{
  
FileInputStream in = new FileInputStream ("myfile.txt")
  
}

//处理
try 

   
new TextEx().f2(); 
catch (IOException e) 

   e.printStackTrace(); 
}
原文地址:https://www.cnblogs.com/sevenyuan/p/1608598.html