package ExceptionHandling;
class PersonalException extends Exception
{
public PersonalException(String s)
{
//constructor with the "super" function
super(s);
}
}
//The class in which you use the "personal exception"
public class ExceptionClass
{
public static void main(String args[])
{
try
{
PersonalException selfMadeException = new PersonalException("hoi");
throw selfMadeException;
}
catch (PersonalException element)
{
System.out.println(element);
}
}
} Why using a try and catch function?