zoukankan      html  css  js  c++  java
  • 第五次实训作业异常处理

     1 package Exception;
     2 import java.util.Scanner;
     3 public class ExceptionTest 
     4 {
     5     public static void main(String[] args) 
     6     {
     7         Scanner sc=new Scanner(System.in);
     8         try
     9         {
    10             System.out.println("请输入两个数:");
    11             int x=sc.nextInt();
    12             int y=sc.nextInt();
    13             int z=x/y;
    14             System.out.println("这两个数相除结果为:"+z);
    15             
    16         }
    17         catch(ArithmeticException e)
    18         {
    19             
    20             e.printStackTrace();
    21         }
    22         finally
    23         {
    24             System.out.println("程序运行结束!");
    25         }
    26         sc.close();
    27         
    28     }
    29 }

  • 相关阅读:
    HDU 1058
    Codeforces 349C
    HDU 2602
    HDU 2571
    HDU 2955
    HDU 2084
    HDU 1003
    HDU 1506 & 1505
    POJ 1854
    HDU 2095
  • 原文地址:https://www.cnblogs.com/pamper/p/10996870.html
Copyright © 2011-2022 走看看