Results 1 to 7 of 7
  1. #1
    jithan is offline Member
    Join Date
    Jun 2008
    Posts
    39
    Rep Power
    0

    Default get exception name

    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 ..........

  2. #2
    pao
    pao is offline Member
    Join Date
    Jun 2008
    Posts
    43
    Rep Power
    0

    Default

    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!

    Java Code:
      try {
                if(true) {
                    System.out.println("throwing exception");
                    throw new ArrayIndexOutOfBoundsException("Example");
                }
            } catch (Exception e) {
                    System.out.println("class = " + e.getClass().toString());
            }
    This will get you the class of the Exception that was thrown, the output is:

    init:
    deps-jar:
    compile-single:
    run-single:
    throwing exception
    class = class java.lang.ArrayIndexOutOfBoundsException
    BUILD SUCCESSFUL (total time: 0 seconds)

  3. #3
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    8

    Default

    I am confused as to what you want here.

    ArrayIndexOutOfBoundsException

    Is the name of the exception.
    Did this post help you? Please me! :cool:

  4. #4
    jithan is offline Member
    Join Date
    Jun 2008
    Posts
    39
    Rep Power
    0

    Default

    s exactly i have to get a class of the exception......... help me.....

  5. #5
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    8

    Default

    Did this post help you? Please me! :cool:

  6. #6
    jithan is offline Member
    Join Date
    Jun 2008
    Posts
    39
    Rep Power
    0

    Default

    thank q friends i got the result.........

  7. #7
    vinaytj is offline Member
    Join Date
    Jun 2008
    Posts
    2
    Rep Power
    0

    Thumbs up

    Quote Originally Posted by jithan View Post
    s exactly i have to get a class of the exception......... help me.....
    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

Similar Threads

  1. exception
    By thamizhisai in forum Advanced Java
    Replies: 9
    Last Post: 05-30-2008, 08:47 AM
  2. Exception
    By rmaadil in forum JDBC
    Replies: 1
    Last Post: 05-19-2008, 12:45 PM
  3. Exception!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 05-05-2008, 01:39 PM
  4. exception
    By Oktam in forum New To Java
    Replies: 2
    Last Post: 03-23-2008, 07:01 PM
  5. Replies: 1
    Last Post: 03-08-2008, 06:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •