java - How to use a method with a char input and a boolean output? -
thank answers ! 1 more question: how print out boolean value? system.out.println(goodbase) not seem work
public class dna { public static void main(string[] args){ abase('a'); } public static boolean abase (char c) { char [] chararray = { 'a', 'g', 'c', 't' }; boolean goodbase; if (c == 'a' || c == 'g' || c == 'c' || c == 't') { return true; } else { return false; } } }
thanks !
the code working me if use in right environment. have attached complete functioning sample below:
public class main { // create test method public static boolean test(char c) { if (c == 'a' || c == 'g' || c == 'c' || c == 't') { return true; } else { return false; } } public static void main(string[] args) { // create sample data string sample = "agctedhi"; // test (int = 0; < sample.length(); i++) { char current = sample.charat(i); system.out.println(current + " " + test(current)); } } }
output:
a true g true c true t true e false d false h false false
Comments
Post a Comment