Can we make the JVM launch our own user-defined exception?

advertisements

In java predefined Exceptions throws automatically. like,

int a=10, b=0;
c = a/b;

throws ArithmeticException

int a[3] = {1, 2, 3};
int b = a[4];

throws ArrayOutOfBoundException

wherein in case of user-defined exceptions we should create an object of that Exception class and throw it manually.Can I make my own Exception to behave like the above two cases?


Can I make my own Exception to behave like the above two cases?

No, it would have to be built into the JVM.