Hour 7. Using Conditional Tests to Make Decisions

What You’ll Learn in This Hour:

• Using the if statement for basic conditional tests

• Testing whether one value is greater than or less than another

• Testing whether two values are equal or unequal

• Using else statements as the opposite of if statements

• Chaining several conditional tests together

• Using the switch statement for complicated conditional tests

• Creating complicated tests with the ternary operator

When you write a computer program, you provide the computer with a list of instructions called statements, and these instructions are followed to the letter. You can tell the computer to work out some unpleasant mathematical formulas, and it works them out. Tell it to display some ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.