DNA Sequencing Solution

In case anyone is struggling with this exercise, I have a variant solution to it. Basically, I used a boolean for the if and else statement to mean that if it contains ATG and TGA and their differences in their index is divisible by 3 with no remainder, then it is a protein. The hints in the site are all types of confusing. I just simplified it.

public class DNA {

public static void main(String[] args) {
	String dna1 = "ATGCGATACGCTTGA";
	String dna2 = "ATGCGATACGTGA";
	String dna3 = "ATTAATATGTACTGA";
	String dna = dna1;
	int ATG = dna.indexOf("ATG");
	int TGA = dna.indexOf("TGA");
	int sequenceDifference = ATG - TGA;
	if (dna.contains("ATG") && dna.contains("TGA") && (sequenceDifference % 3) == 0) {
		System.out.println("Does contain protein!");
	} else {
		System.out.println("Does not contain protein!");



Thank you for this!
The Hints confused me more than helped, but your code was clear and explained the entire process for me.