我的笔记 异常处理try{} catch(Exception e){} throws Exception

    xiaoxiao2021-04-14  40

    try{} catch(Exception e){}   throws Exception finally{}放在catch(Exception e){}后 不管处理怎么样finally{}都会执行  import java.util.Scanner; public class yichang {     public static void main(String[] args)//throws Exception     {         A aa=new A();         try         {             aa.yc();         }         catch(Exception e)         {             System.out.println("输入有误");         }     } } class A{     void yc()//throws Exception     {         Scanner in=new Scanner(System.in);         System.out.println("请输入两位整数");         int a,b,c;         a=in.nextInt();         b=in.nextInt();         c=a%b;         System.out.println(c);     } }
    转载请注明原文地址: https://ju.6miu.com/read-669624.html

    最新回复(0)