I am trying to print out the boolean value, but it does not seem to work (I get an "unreachable statement" error and "missing return statement").
Here is my code:
public class DnaTest {
public static void main(String[] args){
aGoodBase('A');
}
public static boolean aGoodBase (char c) {
char [] charArray = { 'A', 'G', 'C', 'T' };
boolean aBase;
if (c == 'A' || c == 'G' || c == 'C' || c == 'T')
{
return true;
}
else
{
return false;
}
System.out.println(aBase);
}
}
Thanks !
Yeah you missed the return statement at the bottom. In fact, you can write this:
public static boolean aGoodBase (char c) {
char [] charArray = { 'A', 'G', 'C', 'T' };
boolean aBase;
if (c == 'A' || c == 'G' || c == 'C' || c == 'T')
{
aBase = true;
}
else
{
aBase = false;
}
System.out.println(aBase);
return aBase;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments