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

    package dama;
    import java.util.Scanner;
    public class ExceptionTest {
        public static void main(String[] args) {
            // TODO 自动生成的方法存根
            try {
                int x,y;
                Scanner scanner=new Scanner(System.in);
                x=scanner.nextInt();
                y=scanner.nextInt();
                int result=x/y;
                System.out.println(result);
                }
            catch(Exception e) {
                System.out.println("除数不为零");
            }
            finally {
                System.out.println("完成");
            }
        }

    package Input;
    import java.util.*;
    public class MismatchDemo {
         public static double Area(double r)
         {
                return r*r*Math.PI;
            }
         public static void main(String[] args) 
            {
                Scanner sc=new Scanner(System.in);
                try
                {
                    System.out.println("请输入半径:");
                    double r=sc.nextDouble();
                    System.out.println("此圆的面积为:"+Area(r));
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
                sc.close();
            }
    }
    
    

    
    }

     在此次学习中,感觉到异常的简单已经他的难。可以说这个异常处理需要你去深入的了解与探索才可能灵活运用。

  • 相关阅读:
    获取与端点的连接
    判断div内滚动条是否在底部
    MVC的使用!
    格式转换解决存取数据安全问题
    JQuery input file 上传图片
    contenteditable 常用的一些CSS !!
    C# 生成Json类型数据
    生成Excel
    生成验证码
    图片水印
  • 原文地址:https://www.cnblogs.com/quanzhilong/p/10872955.html
Copyright © 2011-2022 走看看