public class NewException extends Exception
{
public NewException()
{
super();
}
public NewException(String message)
{
super(message);
}
}
public class NewExceptionTest
{
public void method(String str)throws NewException
{
if(str==null)
throw new NewException("传入的字符串不能为空");
else
System.out.println(str);
}
//public static void main(String args[])throws NewException
//{
//NewExceptionTest test=new NewExceptionTest();
//test.method("hello");
//}
public static void main(String args[])
{
NewExceptionTest test=new NewExceptionTest();
try
{
test.method(null);
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
System.out.println("异常处理完毕");
}
}
}