提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
逻辑运算符。
public class Main { public static void main(String[] args)/* 来自 n o w j a v a . c o m - 时 代 Java*/ { // create truth table for && (conditional AND) operator System.out.printf("%s%n%s: %b%n%s: %b%n%s: %b%n%s: %b%n%n", "Conditional AND (&&)", "false && false", (false && false), "false && true", (false && true), "true && false", (true && false), "true && true", (true && true)); // create truth table for || (conditional OR) operator System.out.printf("%s%n%s: %b%n%s: %b%n%s: %b%n%s: %b%n%n", "Conditional OR (||)", "false || false", (false || false), "false || true", (false || true), "true || false", (true || false), /** 来自 时代Java - nowjava.com**/ "true || true", (true || true)); // create truth table for & (boolean logical AND) operator System.out.printf("%s%n%s: %b%n%s: %b%n%s: %b%n%s: %b%n%n", "Boolean logical AND (&)", "false & false", (false & false), "false & true", (false & true), "true & false", (true & false), "true & true", (true & true)); // create truth table for | (boolean logical inclusive OR) operator System.out.printf("%s%n%s: %b%n%s: %b%n%s: %b%n%s: %b%n%n", "Boolean logical inclusive OR (|)", "false | false", (false | false), "false | true", (false | true), "true | false", (true | false), "true | true", (true | true)); // create truth table for ^ (boolean logical exclusive OR) operator System.out.printf("%s%n%s: %b%n%s: %b%n%s: %b%n%s: %b%n%n", "Boolean logical exclusive OR (^)", "false ^ false", (false ^ false),