java——throw

2019年2月17日13:51:33 发表评论 1,218 views

发现个好东西: 一个免费短链生成项目:“ https://www.isok.co”一个可以生成所有短链的服务,isok.co的这个含义能覆盖所有短链含义isok, 我试过了很不错,都可以试试

/**
 * Created by xabcd on 2019/2/17.
 */
public class java_throw
{
    public static void main(String args[])
    {
        int a = 4,b = 0;
        try {
            if (b == 0)
                //throw抛出异常的实例对象
            {throw new ArithmeticException("一个算术异常");}
            else
            {System.out.println("a/b="+a/b);}


            }
        catch(ArithmeticException aa){
            System.out.println(aa);
        }
    }
}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: