ArrayList<String> dnaArray = new ArrayList<>();
ArrayList<Character> compArray = new ArrayList<Character>();
// [tac, tat, tta, aaa, aac, aca, aac, ttt]
public void createCompliment() {
for (String letters : dnaArray) {
for (int i = 0, len = letters.length(); i < len; i++) {
char character = letters.charAt(i);
if (character == 'a'){
character = 't';
} else if (character == 'c') {
character = 'g';
}
compArray.add(character);
}
}
}
How would I access specific characters, change 'a' to 't' and similarily from 'c' to 'g'. Then added to a new arraylist and return something like:
[ttg, ttt, ttt, ttt, ttg, tgt, ttg, ttt]
instead of: [t, t, g, t, t, t, t, t, t, t, t, t, t, t, g, t, g, t, t, t, g, t, t, t]
appreciate it
inner.add(foo)and thenif (inner.size() > desired)you doouter.add(inner)andinner = new ArrayList<>()as preparation for the next batch.