1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/* If statement Example This Java Example shows how to use if statement in Java program. */ public class SimpleIfStatementExample { public static void main(String[] args) { /* * If statement is used to execute an action if particular condition is true. * Syntax of if statement is, * * if(<condition>) * <statement> * * while <condition> is a boolean expression, and statement is a valied java * statement which will be executed if <condition> is true. To use multiple * statements, enclose them in a block. * */ boolean blnStatus = true; if(blnStatus) System.out.println("Status is true"); } } /* Output would be Status is true */ |
Add Comment