November 2000
Intermediate to advanced
1152 pages
23h 32m
English
After operators, the next level up is to use conditional statements, and Java supports the same conditional statements as JavaScript: if, if…else, and switch.
The if statement enables you to check a condition, which you create using the Java conditional operators such as <, >, and ==:
if (condition) { code executed if condition is true } else { code executed if condition is false }
For example, say that you had two double variables, assets and debts, and you wanted to compare the two to make sure that you're solvent. You might want the code to display a message, such as You're solvent. You can do that like this (note the \ before the ' in this code; you must add the \ to let Java know that the ...
Read now
Unlock full access