class Ex2
{
static void validate(int age)
{
if(age<18)
throw new ArithmeticException("not valid");
else
System.out.println("age is valid");
}
public static void main(String[] args)
{
try
{
validate(13);
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println("rest of code");
}
}
No comments:
Post a Comment