java.lang.ArrayIndexOutOfBoundsException: 4 Error

All of your calls to arrayCharToInt[x+1] are going to go out of bounds on the last iteration of the loop they’re in (for example, if arrayCharToInt.length equals 5, the highest that x is going to go is 4. But then x+1 equals 5, which is out of bounds for an array with five cells). You’ll need to put in some sort of if( x == arrayCharToInt.length - 1) check.

Leave a Comment