I am getting the \"Must be an array type but it resolved to string\" error in my code. It also says that i (in the code below) cannot be resolved to a variable which I don\'
You using String
incorrectly. Instead of accessing via []
use dna.charAt(i)
.
Altough logically a string is an array of characters in Java a String
type is a class (which means it has attributes and methods) and not a typical array.
And if you want to compare a single character to another enclose it with '' instead of "":
if (dna.charAt(i) == 'c')
.
.