The exception you are getting is a StringIndexOutOfBoundsException which can occur when no such character is in bounds of a string. The problem you had is that with dna.indexOf(startIndex), you are...