Throw Example
public class Example{
void checkAge(int age){
if(age<18)
throw new AirthmaticException("Not Eligible for voting");
else
System.out.println("Eligible for voting");
}
public static void main(String args[])
{
Example obj = new Example();
obj.checkAge(13);
}
}
Throws Example
public class Example1{
int division(int a, int b) throws AirthmaticException{
int t = a/b;
return t;
}
public staic void main(String args[]){
Example1 obj = new Example1();
obj.division(15,0);
}
}
0 Comments