O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Try This 2-2 Display a Truth Table for the Logical Operators

LogicalOpTable.java

In this project, you will create a program that displays the truth table for Java’s logical operators. You must make the columns in the table line up. This project makes use of several features covered in this chapter, including one of Java’s escape sequences and the logical operators. It also illustrates the differences in the precedence between the arithmetic + operator and the logical operators.

1. Create a new file called LogicalOpTable.java.

2. To ensure that the columns line up, you will use the \t escape sequence to embed tabs into each output string. For example, this println( ) statement displays the header for the table:

3. Each subsequent line in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required