More on Flow of Control

There are three general situations where flow of control changes from being just one line after the other.

We've already seen how conditional blocks work, and we will shortly look at methods and loops. But basically, a method is another chunck of code that is called, and so flow of control goes there until the method finishes. And a loop is where one part of the code gets repeated again and again.

In looking through the traces below, first note what variables a, b, and c are, since their values will determine what the conditional "diamonds" eveluate to.

In Trace # 1, the flow of control is pretty straight forward, except for the conditional line 3 evaluating to false, and so going from 3 to 13, down to 19, and then finishing off with lines 11 and 12.


In Trace # 2, the first variation from straight forward flow is at line 6, where method1 is called.


The flow of control in Trace # 3 is more complex, since the evaluations of two conditional lines affect it, but so too does a call to method2(), and also there is a loop of lines 21 and 22.