java异常

public class MyException extends Exception{
	public MyException()
    {
        super();
    }
	
    public MyException(String name)
    {
        super(name);
    }
    
    public static void main(String args[]) throws MyException{
    	try{
    		Integer i = new Integer(-1);
    		
    		if(i < 0)
            {
                throw new MyException();
            }
        
    	}
    	catch(MyException e){
    		System.out.println("有错误");
    	}
    }
        
        
        
}

  

posted @ 2015-11-24 17:48  喵小喵~  阅读(143)  评论(0编辑  收藏  举报