这就是我所拥有的:
public class A1tester {
static String dna = "GCTTTA";
static String dna1 = "GCTAAAAAD";
public static void main(String[] args) {
validChars(dna);
validChars(dna1);
}
private static boolean validChars(String dna) {
try {
for (char c: dna.toCharArray()) {
assert ((c == 'C') || (c == 'G') || (c == 'T') || (c == 'A'));
}
} catch (Exception e) {
System.out.println("Exception caught!");
return false;
}
System.out.println("DNA has only the permitted letters");
return true;
}
}
我错过了什么阻止我的 validChars() 方法将 dna1 识别为包含四个允许的字符以外的字符?
谢谢。