I am trying to figure out part of an assignment and I have been beating my head against a wall for some time now. I\'m trying to transcribe DNA sequences to RNA sequences. I am,
You want 1 less than size , so : if (pos1 >= linkedList.size()) {
.
When pos1 == linkedList.size()
it will be out of bounds
The problem is in the statement arr[a] ='U';
The problem is that char
is represented as an int
internally and 'T'
equals 84 hence you get an ArrayIndexOutOfBoundsException
.
You need to iterate over it with a traditional counter:
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 'T') {
arr[i] ='U';
}
}