/Users/lyon/j4p/src/bookExamples/ch03Ops/LogicalOperators.java

1    package bookExamples.ch03Ops; 
2     
3    public class LogicalOperators { 
4        boolean tt [][] = { 
5            {false, false}, 
6            {false, true}, 
7            {true, false}, 
8            {true, true} 
9        }; 
10    
11       public static void main(String args[]) { 
12           LogicalOperators lo 
13                   = new LogicalOperators(); 
14           lo.println(); 
15       } 
16    
17       public void println() { 
18           System.out.println("TruthTable"); 
19           System.out.println("a\tb\ta&&b\ta||b\t!a"); 
20           for (int x = 0; x < tt.length; x++) { 
21               boolean a = tt[x][0]; 
22               boolean b = tt[x][1]; 
23               System.out.println(a + "\t" + b + "\t" 
24                       + (a && b) + "\t" 
25                       + (a || b) + "\t" 
26                       + (!a)); 
27           } 
28       } 
29   } 
30