if (boolean-expression) {
statement(s) ;
}
Contoh Percabangan If :
public class Logika_if {
public static void main (String args []){
int targetnilai=60;
boolean lulus=false;
int nilai=70;
if (nilai > targetnilai){
lulus=true;
}
System.out.println("Status kelulusan:"+lulus);
}
}
Output:
Status kelulusan:true
Tags:
Java