zoukankan      html  css  js  c++  java
  • 36.java_exception_test

    package mytext1;

    class TZException extends Exception{
    TZException(String str){
    super(str);
    }
    public String toString(String msg){
    String tempt="the actual exception lies:"+msg+" ";
    return tempt;
    }
    }

    class TZ{
    private String message;
    private static int count=0;
    TZ(String msg){
    count++;
    message=msg;
    }
    public void test(int flag) throws TZException{
    if(flag==1){
    throw new TZException(message);
    }
    }
    public int getcount(){
    return count;
    }
    }

    public class mytext1{
    public static void main(String args[])
    {
    try
    {
    TZ obj=new TZ("test1");
    obj.test(1);
    }
    catch(Exception e){
    System.out.println(e.toString());
    }
    finally{
    System.out.println("over");
    }
    }
    }

  • 相关阅读:
    8.09_python_lx_shopping
    8.06_python_lx_day25
    8.05_python_lx_day24
    8.05_python_lx_day23
    8.03_python_lx_day21<2>
    Java注解
    Java多线程04
    Java多线程03
    Java多线程02
    Java多线程01
  • 原文地址:https://www.cnblogs.com/acm-icpcer/p/6647109.html
Copyright © 2011-2022 走看看