Control Flow Looping by Using For

Assoc. Prof. Leon Abdillah

Control Flow Looping by Using For

Leon Andretti Abdillah


—There may be a situation when we need to execute a block of code several number of times, and is often referred to as a “loop”. Other terminology could be “repetition” or “iteration”.

—Java has very flexible three looping mechanisms. You can use one of the following three loops:


—Structure control, consists of:

  1. Sequence
  2. Selection/Choice/Decision (if..else.. dan
  3. Loop/Iteration/Repetition (while, do..while, for..)


—The for statement continually executes a block of statements while a particular condition is true.

—Its syntax can be expressed as:

for(initialization; Boolean_expression; update) {   //Statements



for (initialization_expression ; loop_condition ; increment_expression) {
// statements




Java Code

package eLooping;

public class eLooping3ForSum {

public static void main(String[] args) {
// TODO Auto-generated method stub
int Jum = 0;
for(int i=1; i<=5; i++){
Jum += i; // Jum = Jum + i;
System.out.println(“Jumlah = ” + Jum);



C. H. Chuan. Introduction to Java Programming (for Novices & First-Time Programmers).  Retrieved from


L. A. Abdillah. (2013). Algorithms & Programming. Available:

L. A. Abdillah. (2014). Data Structures & Algorithms. Available:

L. A. Abdillah. (2016). Algorithms & Data Structures. Available:


Leave a Reply

Your email address will not be published. Required fields are marked *