© Ron Dai 2019
R. DaiLearn Java with Mathhttps://doi.org/10.1007/978-1-4842-5209-3_10

10. Logical Control Structures

Ron Dai1 
(1)
Seattle, WA, USA
 
Very similarly to how we describe it verbally when there is a logical conversation, the if and the if/else in programming languages are common structures to make conditional decisions and choose corresponding execution paths (Figure 10-1).
../images/485723_1_En_10_Chapter/485723_1_En_10_Fig1_HTML.png
Figure 10-1

The if structure

if (a == 3) {
       <do something>
}
This is similar to, but not completely the same, as:
if (a == 3) {
       <do something>
} else {
       <do something else>
}
Figure 10-2 is the whole workflow of the if/else logical control structure.
Figure 10-2 ...

Get Learn Java with Math: Using Fun Projects and Games 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.