I want to find multiple hits with the indexOf method.
I have got this line to search in:
public static final String DNA = "ATGTTGCTGGCATAGATGTTAACTTCCAC";
For example i would like to search the locations of AC in this String. I want to do that with this method. At the moment i only get 21 a couple of times. As i should get 21 and 27 ones.
public int[] zoek(String gezocht)
{
// goed = 21+27 bij AC
int fromIndex = 0;
for (int i = 0; i < DNA.length(); i++)
{
fromIndex = DNA.indexOf(gezocht, fromIndex);
dna.add(fromIndex);
}
System.out.println(dna);
return zoek;
}