There are 3 basic control structures for Java:
- Sequential - This means that all Java statements are executed line-by-line, one after another. This is already inherent within the language itself as you write the codes.
- Selection - This control structure instructs the computer to make a selection (or branching) of the portion of the program based on a decision, made by doing a comparison. There are 2 selection structures in Java, the if() and switch() structures.
- Repetition - This structure instructs the computer to perform a repetition of a block of code, and there various methods to terminate the repetition. There are 3 repetition structures, the for() loop, the while() loop and the do-while() loop.
No comments:
Post a Comment