hello friends,
i have to get a exception name ........ in the following example .......... pls help me......
java.lang.ArrayIndexOutOfBoundsException: 4
at exec.main(exec.java:7)
here i have to get exception name ..........
Printable View
hello friends,
i have to get a exception name ........ in the following example .......... pls help me......
java.lang.ArrayIndexOutOfBoundsException: 4
at exec.main(exec.java:7)
here i have to get exception name ..........
Do you mean the class of the Exception? If you do then I can help a little, if you actually mean 'Name' then I don't know!
This will get you the class of the Exception that was thrown, the output is:Code:try {
if(true) {
System.out.println("throwing exception");
throw new ArrayIndexOutOfBoundsException("Example");
}
} catch (Exception e) {
System.out.println("class = " + e.getClass().toString());
}
init:
deps-jar:
compile-single:
run-single:
throwing exception
class = class java.lang.ArrayIndexOutOfBoundsException
BUILD SUCCESSFUL (total time: 0 seconds)
I am confused as to what you want here.
ArrayIndexOutOfBoundsException
Is the name of the exception.
s exactly i have to get a class of the exception......... help me.....
What pao posted should help you.
ArrayIndexOutOfBoundsException (Java 2 Platform SE v1.4.2)
thank q friends i got the result.........
ArrayIndexOutOfBoundsException is itself only the class name of that exception.
i think you are passing values through command line in the program "exec".
if so , do like this
ex,,
Public static void main(String s[])
{
try{
write your code here,,,,,
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
}
}// end of main
i hope it works,,,,
Regards
Vinay TJ