Decision Making
There are two sorts of decision making constructs in Java. They are:
if
constructs
switch constructs
The if Statement:
An if constructs comprises of a Boolean outflow emulated by one or more proclamations.
The syntax for using this construct is as follows:
if(
) {
//Statements if the condition is true
}
In the event that the Boolean construct assesses to true, then the scope of code inside the if
proclamation will be executed. If not the first set of code after the end of the if construct
(after the end wavy prop) will be executed.
Sample Implementation:
public class myTest {
public static void main(string args[]){
int i = 0;
if( i < 1 ){
System.out.print(“The if construct is executing!”);
}
}
This would create the accompanying result:
The if construct is executing!
Do'stlaringiz bilan baham: