Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8962513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:08:35+00:00 2026-06-15T16:08:35+00:00

I am getting an array index out of bounds exception in the following code:

  • 0

I am getting an array index out of bounds exception in the following code:

for (int i=1; i<11; i++) {
    int a[][] = new int[10][3];
double LeftTrim = 1.0;
double RightTrim = 1.0;

a [i][0]=(int) (LeftTrim*((i)*25));
a [i][1]=(int) (RightTrim*((i)*25));
a [i][2]= 5000;

//leftWheel, rightWheel, Milliseconds
myf.setWheelVelocities(a[i][0], a[i][1], a[i][2]);
JOptionPane.showMessageDialog(null, + (a [i][0]  +  a [i][1])/2 + "wheel velocities"  + " | " + a [i][2] + " Milliseconds" +  " Click OK to continue...");
}

Every-time I reach the 9th increment Eclipse gives me the error

"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10"

I have to test the velocity up to 250, but when I reach 225 and I click ‘Ok’ on ‘Click ok to continue…” this error shows up! Am I going out of the array bounds or something?

EDIT: The speed velocity has to start from 25, 50, 75 … 250 (so ten in all)

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:08:36+00:00Added an answer on June 15, 2026 at 4:08 pm

    The valid values of i in a[i] are 0 to 9. Your code iterates to 10.

    Also, the loop starts from 1 whereas it might need to start from 0.

    Finally, the fact that you’re allocating the 2D array inside the loop look pretty odd. Either move it outside the loop, or turn it into a three-element 1D array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm getting an index out of bounds exception on some code i'm writing.
I am getting the following index out of bounds error: *** Terminating app due
I seem to be getting an array out of bounds exception but the problem
I'm getting this error: [NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array although
I am getting Index was outside the bounds of the array. error when using
Hello I am currently getting an index out of range error from the following
I'm getting an out of bounds exception on the calendarTable[i][j] = str; line below.
I am getting this error on the following code, and cant figure out why.
I am trying to execute the following code and I keep getting an Index
I keep gettting array index out of bounds? Iv'e tried with changing mymatches.Count to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.