Results 1 to 8 of 8
  1. #1
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default exception syntac help

    I have :

    IndexOutOfBoundsException - if fromIndex or toIndex is out of range (fromIndex < 0 jj fromIndex >= size() jj toIndex > size() jj toIndex < fromIndex)

    this is for a method, and I was just wondering how I use this.
    Like where do I put the brackets etc? Can someone just help me with where to put the brackets.


    public void method(int h, int k)

    {
    //method
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,987
    Rep Power
    9

    Default Re: exception syntac help

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: exception syntac help

    I don't have problems with the method, the method I have completed. I just don't understand where to put the exception statements. could you clear this up for me please.
    much appreciated.

  4. #4
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: exception syntac help

    anyone?

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: exception syntac help

    where to put the exception statements.
    Are you throwing, catching or creating exceptions?

  6. #6
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: exception syntac help

    throwing them
    IndexOutOfBoundsException - if fromIndex or toIndex is out of range (fromIndex < 0 ||fromIndex >= size() || toIndex > size() || toIndex < fromIndex)

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: exception syntac help

    You use the throw statement to throw an exception. For example;
    Java Code:
    if(<there is an exceptional condition>) {
         // Here we have detected an exceptional condition and will throw and exception
         throw new Exception("My exception");
    }

  8. #8
    endotherm is offline Member
    Join Date
    Mar 2012
    Posts
    9
    Rep Power
    0

    Default Re: exception syntac help

    the general syntax of a try-catch is:
    Java Code:
    try{
        ...dangerous code goes here
    
    }catch(SpecificExceptionType e){
        ...type specific recovery or reaction code goes here.
    
    }catch(Exception e){
        ...error recovery or reaction code goes here.
    
    }

Similar Threads

  1. unreported exception java.lang.Exception
    By Marisabel in forum New To Java
    Replies: 6
    Last Post: 05-01-2011, 03:21 AM
  2. Replies: 5
    Last Post: 02-14-2011, 11:39 PM
  3. Replies: 1
    Last Post: 02-06-2011, 05:38 AM
  4. Replies: 4
    Last Post: 10-25-2010, 07:42 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
  •