Computer Science Canada Arrray Error |
Author: | slider203 [ Sun Apr 11, 2010 1:00 pm ] | ||
Post subject: | Arrray Error | ||
Hello I made a program that takes a number between 6 and 9 from the user then outputs all days with that number of letters in the name (e.g. 6 monday,sunday,friday) I have that part working but everytime I run the program It outputs an error after
|
Author: | DemonWasp [ Sun Apr 11, 2010 2:04 pm ] |
Post subject: | RE:Arrray Error |
You need to post all the source code and also post the error message. Preferably, you'd point out which line the error message lists as well. |
Author: | slider203 [ Sun Apr 11, 2010 3:12 pm ] | ||
Post subject: | Re: Arrray Error | ||
Hello DemonWasp that is all of my code the only thing above that is this:
The error message is: Quote: java.lang.ArrayIndexOutOfBoundsException: 7 at arrayPrac4.main(arrayPrac4.java:56) Thanks for your time |
Author: | TheGuardian001 [ Sun Apr 11, 2010 3:31 pm ] |
Post subject: | Re: Arrray Error |
Your for loop runs from 0 to MAX_COUNT, which is 9, but there are only 7 elements in your array. You should be going through based on how many values you're storing, not the maximum value being stored. |
Author: | slider203 [ Sun Apr 11, 2010 3:43 pm ] |
Post subject: | RE:Arrray Error |
Once again thanks Guardian this solved my problem. Im just not understanding arrays at all |