I need help understanding how to turn this ternary to if statement
int intP = p ? 1 : 0
Thanks
here's the whole code:
class logtable {
public static void main(String args[]) {
boolean p = true, q = false;
int intP = p ? 1 : 0;
int intQ = q ? 1 : 0;
int S = (!p) ? 1 : 0;
System.out.println("p\tq\tAND\tOR\tXOR\t!p");
System.out.println(intP + "\t" + intQ + "\t" + (intP&intQ) + "\t" + (intP|intQ) + "\t" + (intP^intQ) + "\t" + S);
}
}
Aucun commentaire:
Enregistrer un commentaire