class ControlFlowDemo
{
public static void main(String[] args)
{
boolean flag = false;
if (flag)
{
System.out.println("flag is true,inside if block.");
}
else
{
System.out.println("flag is false,inside else block.");
}
}
}
Output flag is false,inside else block.
IfElseDemo.java class IfElseDemo
{
public static void main(String[] args)
{
int testscore = 81;
char grade;
if (testscore >= 90)
{
grade = 'A';
}
else if (testscore >= 80)
{
grade = 'B';
}
else if (testscore >= 70)
{
grade = 'C';
}
else if (testscore >= 60)
{
grade = 'D';
}
else
{
grade = 'F';
}
System.out.println("Grade = " + grade);
}
}