nooby nooby - 4 months ago 16
Java Question

Java how to check which condition is true

Is there anyway to make the program say which condition is correct?

public static void main(String[] args) throws IOException, InterruptedException {
Boolean a = true;
Boolean b = false;
Boolean c = null;
if (a == true || b == false || c == true) {
System.out.println("Test");
}
}
}


Since
a
is the only one that is correct, would there be away too make it print "a is the only condition that is correct"

Answer
if (a) {
    System.out.println("a is the condition that is correct");
}
//Edit by comment. Thanks
if (!b) {
    System.out.println("b is the condition that is correct");
}

if (c) {
    System.out.println("c is the condition that is correct");
}