[Solved] What does ArrayIndexOutOfBoundsException mean and how do I get rid of it? Here is a code sample that triggers the exception: [closed]


From inspection, I can see that your month array is missing the month of May, and therefore only has 11 elements in it. As a result, when you iterate over the 12 elements in the temperature array, you will get an array out of bounds exception during the final temperature, because there is no corresponding enter in month at that position.

To fix this, just make sure that month and temperature are the same size:

String [] month = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec" };

1

solved What does ArrayIndexOutOfBoundsException mean and how do I get rid of it? Here is a code sample that triggers the exception: [closed]