String index out of range -8
<p>I don't absolutely see a reason why the index is out of range. 
the start is from the letters <code>atg</code> in the string <code>ataaactatgttttaaatgt</code> and ends with <code>taa</code>. What am I missing here?</p>

<p>Edit: This is the line right here       </p>

<p><code>String subStr1 = dna.substring(start,stop1);</code></p>

<pre><code>/**

 *
 * @author Duke Software Team 
 */
import edu.duke.*;
import java.io.*;

public class TagFinder2 {


  public String findProtein(String dna) {
    int start = dna.indexOf("atg");

    int stop1 = dna.indexOf("tag", start+3);
    int stop2 = dna.indexOf("tga",start+3);
    int stop3 = dna.indexOf("taa",start+3);


    String subStr1 = dna.substring(start,stop1);
    String subStr2 = dna.substring(start,stop2);
    String subStr3 = dna.substring(start,stop3);

    String result;

    if( subStr1.length() % 3 ==0 ){
      return subStr1;
    } else if (subStr2.length()%3==0){
      return subStr2;
    } else if (subStr3.length()%3 == 0) {
      return subStr3;
    } else {

      return "";
    }
  }

  private void stopCodon(String gene){
    //This prints out the last 3 characters of the gene

    String stopCodon = gene.substring(gene.length() - 3);
    System.out.println(stopCodon);
  }

  public void testing() {
    String a = "ataaactatgttttaaatgt";
    String b = "acatgataacctaag";
    String c = "AATGCTAGTTTAAATCTGA";

    String result = findProtein(a);

    stopCodon(result);

  }
  //public String stopCodon(String dna){
  //   return 
  //  }


}
</code></pre>