A program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception if the character that u have passed is digit.
class MyException extends Exception { privatechar detail; MyException(char c) { detail=c; } public String toString() { return"MyException["+detail+"]"; } } class MyExc { staticvoid myfunc(char ch) throws MyException { System.out.println("Called myfunc("+ch+")"); if(ch=='0' || ch=='1' || ch=='2' || ch=='3' || ch=='4' || ch=='5' || ch=='6' || ch=='7' || ch=='8' || ch=='9') thrownew MyException(ch); System.out.println("Normal Exit..."); } publicstaticvoid main(String args[]) { try { myfunc('g'); myfunc('7'); } catch(MyException e) { System.out.println("Caught "+e); } } } /* OutputCalled myfunc(g)Normal Exit...Called myfunc(7)Caught MyException[7]*/