Are you validating the length of the String before you use charAt()? Maybe the String is not as long as you think it is. If a String's length is 0, it has *no* valid indexes.