e.p e.p - 6 months ago 9
Java Question

Creating my own class exception

I cant understand what it does this code.Also, i have a main that i throw this exception .Could you explain me what it does RuntimeException,super s and etc?

public class InvalidException extends RuntimeException{

public InvalidException (String s){
super(s);
}
}

Answer

Concerning what RuntimeException does, you may refer to the official JavaDocs https://docs.oracle.com/javase/7/docs/api/java/lang/RuntimeException.html

super (when used in a constructor) calls the constructor of the class from which you inherited (here: RuntimeException). For more details refer to https://docs.oracle.com/javase/tutorial/java/IandI/super.html

Comments