java - Boolean and conditionals in order -
so below have , method returns true if second condition met. however, want return false if first condition met. however, problem returns false times.
public static boolean matching(request a, request b) { if (a.info[2].equals("*") & b.info[2].equals("*")) { return false; } return ((a.info[1].equals(b.info[1]) && a.info[2].equals(b.info[2])) || (a.info[1] .equals(b.info[1]) && a.info[2].equals("*") || b.info[2] .equals("*"))); }
without trying understand whole conditional sentences, i'm guessing have typo here.-
if (a.info[2].equals("*") & b.info[2].equals("*")) {
and meant
if (a.info[2].equals("*") && b.info[2].equals("*")) {
instead.
you can take this old thread further information.
edit
if problem persists, chances there're issues on second conditional sentence. best can setting breakpoint display relevant values during runtime; should see what's going wrong.
Comments
Post a Comment