If-else Statement in java

Java Programming Language Decision Making in java (Article) Decision Making in java (Program)

1793

Program:

<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>&gt;</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>(&quot;Age is greater than 18&quot;);
      }
   }
}
</b></font>
</code>

Output:

Age is greater than 18
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.