Aim:- Show the implementation of
‘throw’ keyword.
import java.lang.*;
class ThrowDemo
{
static void demo()
{
try
{
throw new
NullPointerException("demo");
}
catch(NullPointerException
e)
{
System.out.println("Caught inside
demo...");
throw e;
}
}
public static void main(String[] args)
{
try
{
demo();
}
catch(NullPointerException
e)
{
System.out.println("Recaught...");
}
}
}
Output:-
No comments:
Post a Comment