<code><font size=2 face="Consolas"><font color="#FF0000"><b>public class </b></font><font color="#0066CC"><b>IfExample </b></font><b>{
</b><font color="#FF0000"><b>public </b></font><font color="#800000"><b>static void </b></font><font color="#0066CC"><b>main</b></font><b>(</b><font color="#0066CC"><b>String</b></font><b>[] </b><font color="#0066CC"><b>args</b></font><b>)
{
</b><font color="#800000"><b>int </b></font><font color="#0066CC"><b>age</b></font><b>=</b><font color="#FF0000"><b>20</b></font><b>;
</b><font color="#FF0000"><b>if</b></font><b>(</b><font color="#0066CC"><b>age</b></font><b>></b><font color="#FF0000"><b>18</b></font><b>){
</b><font color="#0066CC"><b>System</b></font><b>.</b><font color="#0066CC"><b>out</b></font><b>.</b><font color="#0066CC"><b>println</b></font><b>("Age is greater than 18");
}
}
}
</b></font>
</code>
Age is greater than 18
Press any key to continue . . .
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.