Chapter 7. Using Conditional Tests to Make Decisions
WHAT YOU’LL LEARN IN THIS HOUR:
Using the
if
statement for basic conditional testsTesting whether one value is greater than or less than another
Testing whether two values are equal or unequal
Using
else
statements as the opposite ofif
statementsChaining several conditional tests together
Using the
switch
statement for complicated conditional testsCreating 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 ...
Get Sams Teach Yourself Java™ in 24 Hours, Fifth 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.