[Solved] Getting java.lang.ArrayIndexOutOfBoundsException, looked, cannot find an example thats the same


In your for loop, i correctly iterates from 0 to the maximum length. However you have code such as:

 tweetArray[i+1]
 ...
 tweetArray[i+7]

that will fail once i reaches (or gets close to) its maximum. That is, you are referencing past the end of the array.

In general, if you need to check something about the next character, you need to check that it exists first (as you only know that the current character exists).

You may wish to review your whole approach though. There does not appear to be any need to split your string into characters. You could instead use string based functions to count the number of @ characters or check for the presence of a string (eg. http://). Check out the API.

3

solved Getting java.lang.ArrayIndexOutOfBoundsException, looked, cannot find an example thats the same