I want to "get around" the strict restrictions placed on methods by the throws clause.
So I decided to subclass RuntimeException
to make up a new, exempt exception of my own. Now I can throw it to my heart's content, because the throws clause that was annoying me does not need to include this new exception but the code is not working.
public class Cnf extends RuntimeException {
public Cnf(){};
}
public class Example1 {
public static void main(String args[]) {
if(Class.forName("GeeksForGeeks")==null){
throw new Cnf();
else
System.out.println("Hello");
}
}
}