The exception must be thrown somewhere in your code using throw
keyword.
For example,
The ArithmeticException
is thrown some where deep inside the code . If you don't want to handle( just like how the person thought about writing ArithmeticException
) you can bubble up like
void someMethod () throws Exception
{
throw new Exception();
}
The person who called this method have to handle it with try
,catch
, finally
like we usually do for exceptions IOException
etc.
So, if you want to throw your exception, add this throw new LinkedListException()
some where in your try block where ever you want to raise an exception.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…