Java – What is Sequential Code Execution?

java

I have been looking around on the internet and have not found a good answer yet. If anyone could be so kind and supply a code sample I would greatly appreciate it. I apologize for the simplicity of the question.

Best Answer

This is the simplest one of all: it's when your instructions are executed in the same order that they appear in your program, without repeating or skipping any instructions from the sequence.

For example, this is sequential execution:

int a = 5;
int b = 12;
int c = a*a + b + 7;

On the other hand, this is not sequential execution, because one instruction is going to be skipped.

int a = 5;
int b = 12;
int c;
if (a > b) {
    c = a;
} else {
    c = b;
}
Related Topic