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: Array index out of bounds

  1. #1
    Member
    Join Date
    Oct 2010
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Array index out of bounds

    Hi Guys i keep getting this error "java.lang.ArrayIndexOutOfBoundsException: 9" I have been stuck with it for a while and cannont copntinue find out how to sort it. please can you guys have a look and see if you can help

    while(true)
    {
    c=0;
    s1=""; // colum
    System.out.println("--------------------------------------------- ---------------------------");
    System.out.print("Enter columns Sequence between 1 to "+numberofcols+" : ");
    st="192837465";
    char st1[]= {1,9,2,8,3,7,4,6,5};
    d=st+d;
    System.out.println();
    System.out.println("Ecfsdfsdfsdfsdt : ");
    for(int i=0;i<numberofcols;i++)
    {
    c=(int)st1[i]-1;
    System.out.println("(int)st.charAt(i) ="+(int)st.charAt(i));
    System.out.println("c="+c);
     
    for(int j=0;j<numberofrows;j++)
    {
     
    if(a[j][c]!='$')
        System.out.println("fail here"); // ithink the problem is around these lines
    s1=s1+a[j][c];
    }
    }
     
    s1.trim();
    c=0;
    for(int i=0;i<numberofrows;i++)
    for(int j=0;j<numberofcols;j++)
    if(c<s1.length())
    a[i][j]=s1.charAt(c++);
    else
    a[i][j]='$';
     
     
    System.out.println();
    System.out.println();
     
    System.out.println("********************************************* *******************");
    System.out.println();

    THANK YOU


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Array index out of bounds

    Can you please post all of your code so I have something to compile...
    Thanks.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. String index out of bounds error 5???
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 26th, 2010, 07:11 PM
  2. index of array
    By nasi in forum Java Theory & Questions
    Replies: 1
    Last Post: April 12th, 2010, 02:39 AM
  3. [SOLVED] Using class implicit toString() for array index
    By Quetzalma in forum Java Theory & Questions
    Replies: 2
    Last Post: February 3rd, 2010, 04:04 PM
  4. Index Out Of Bounds
    By chronoz13 in forum Collections and Generics
    Replies: 1
    Last Post: December 28th, 2009, 11:19 AM
  5. Having problems with String out of bounds errors
    By Bill_H in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 27th, 2009, 01:47 PM