Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java.lang.ArrayIndexOutOfBoundsException

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java.lang.ArrayIndexOutOfBoundsException

    Name[] n = new Name[index?ninds:nsyms];
    int j = 0;
    for(int i=0;i<defined.length;i++){
    if( defined[i] == 0 )
    continue;
    Name tn = Name.get(i);
    if(tn==null)continue;
    if( tn.isIndex() != index )
    continue;
    n[j++] = tn; am getting error here
    }
    for(int i=1;i<n.length;i++){
    Name tn = n[i];
    if(tn==null)continue;
    String t = n[i].getSortKey();
    j = i - 1;
    while( j >= 0 && n[j].getSortKey().compareTo(t) > 0 ){
    n[j+1] = n[j];
    --j;
    }
    n[++j] = tn;
    }
    return n;
    }

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: java.lang.ArrayIndexOutOfBoundsException

    When posting code, please use the highlight tags. Unformatted code is very hard to read. Also, code should be posted in the form of an SSCCE. What is the actual text and stack trace of the error?

    How many indexes does that array have? What index are you trying to access? Use a debugger or print statements to figure out exactly what's going on.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. java.lang.ArrayIndexOutOfBoundsException - huh?
    By mrUnknown in forum Exceptions
    Replies: 3
    Last Post: February 18th, 2012, 09:06 AM
  2. Help! ArrayIndexOutOfBoundsException
    By ray3 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: December 1st, 2011, 06:21 PM
  3. [SOLVED] java.lang.ArrayIndexOutOfBoundsException
    By anmaston in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 12th, 2011, 04:43 PM
  4. ArrayIndexOutOfBoundsException
    By NightFire91 in forum Exceptions
    Replies: 1
    Last Post: October 31st, 2010, 06:06 AM
  5. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM