public class Booleans { public static void main(String args[]) { boolean result; int a, b; a = 396; b = 49; // all of the following are true: result = 42 == (41+1); // same value: 42 result = 42 >= 42; result = 'A' < 'B'; // 'B' falls later in alphabet result = 'A' == 65; // ASCII code for 'A' is 65 result = Math.sqrt(4.0) == 2.0; // no roundoff...yet result = ((a/b)*b + (a%b)) == a;// always true result = a == a; // any value == itself result = (a != a) == false; result = !false; result = true == true; // they're the same // all of the following are false: result = 42 != 42; // these are equal result = !(42 == 42); result = 'a' == 'A'; // upper and lower are different result = Math.sin(Math.PI/6) == 0.5; // roundoff error result = !true; // false is "not true" result = true == false; // they're not the same result = (100 < a) && (a < 200); /* result = 100 < a < 200; result = ((100 < a) < 200); */ result = (100 > a) && (a > 200); result = (100 > a) || (a < 200); } }