Struktur Kontrol Java

You might also like

You are on page 1of 12

Branching & Looping

Fikri Fadlillah, S.T


Prerequisites Today

Installed Java Development Kit


Installed Text Editor
Having one laptop for each group
Branching type

If - then
If – then – else
Switch - case
If statement

Source : www.tutorialspoint.com/java/if_statement_in_java.htm
If-else statement

Source : www.tutorialspoint.com/java/if_else_statement_in_java.htm
Switch-Case statement

Source : www.tutorialspoint.com/java/if_else_statement_in_java.htm
Syntax of Branching

If - Then If-Then-Else Switch - Case


If (condition) If (condition){ Switch (var_name){
{ case value_1:
statement_1; Statement_1
break;
statement;
case value_2:
} Statement_2
} else if (condition_2) break;
{ case value_n:
Statement_n;
statement_2; Break;
default:
} statement;
else { break;
statement_3;
}
Looping Type

While Loop
Do – While Loop
For Loop
While Loop

Source : tutorialspoint.com/java/java_while_loop.htm
Do - While Loop

Source : tutorialspoint.com/java/java_do_while_loop.htm
For Loop

Source : tutorialspoint.com/java/java_do_while_loop.htm
Syntax of Looping

While loop do..while loop For loop


while do for(init.; cond.; inc.){
(condition) { Statements;
{ Statements; }
}
Statements; while(condition
);
}

You might also like