User-defined exceptions: - These are the exceptions created by user of the language.
Creating user defined exceptions: -
a) Write user exception class as a sub class to exception class
Ex: - class MyException extends Exception
b) Write a default constructor in user exception class
Ex – MyException( ) { }
c) Write a string parameterized constructor & from their call the super class constructor.
Ex: - MyException(String str)
{
Super(str);
}
d) To raise the exception creates user exception class object & throw it using throw statement.
Ex: - throw me;
Sur cette page du site, vous pouvez voir la vidéo en ligne Java User-defined exceptions: durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Java code&Decode 22 février 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 97 fois et il a aimé 8 téléspectateurs. Bon visionnage!