class Age {
publicvoidsetAge(int age) throws Exception{
if (age < 12 && age > 0){
System.out.println("This is a child");
}elseif(age >= 18){
System.out.println("This is a adult");
}elseif(age >=12 && age < 18){
System.out.println("This is a youth");
}else{
Exception e = new Exception("The age can't be negative number");
throw e;
}
}
}
publicclass TestDemo {
publicstaticvoidmain(String args[]){
Age a = new Age();
try{
a.setAge(-1);
}
catch(Exception e){
System.out.println(e);
}
finally {
System.out.println("The End");
}
}
}