java自定义Exception

时间:2014-04-30 22:32:40   收藏:0   阅读:250
public class JavaTest
{
	public static void main(String[] args)
	{
		try
		{
			throw new DefaultException("This is a defined Exception!");
		}
		catch(DefaultException e)
		{
			System.out.println(e);
		}
	}	
}

class DefaultException extends Exception
{
	public DefaultException(String msg)
	{
		super(msg);
	}
}
mamicode.com,码迷
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!