Java第五次实训作业

异常处理

package LHB.inherit;
import java.util.*;
public class ExceptionTest
{
 
 public static void main(String[] args)
 {    
     try 
     {  
         Scanner in=new Scanner(System.in);
         int x,y,z;
         System.out.print("请输入两个数:");
         x=in.nextInt();
         y=in.nextInt();  
         z=x/y;
         System.out.print("结果是:");
         System.out.println(z);
         }    
     catch(ArithmeticException e)    
     {    
         e.printStackTrace();  
     } 
     finally
     {  
         System.out.println(6666);
     }
     }
 
}

 

转载于:https://www.cnblogs.com/cocacolaohh/p/11028346.html

你可能感兴趣的:(Java第五次实训作业)