This example illustrates how you can utilize if..else to “unlock a door” when the user inputs the correct code.
int if  | 
This example demonstrates how if..else can be used to determine whether a number is positive or negative.
int myNum = 10; // Is this a positive or negative number? if (myNum > 0) { System.out.println("The value is a positive number."); } else if (myNum < 0) { System.out.println("The value is a negative number."); } else { System.out.println("The value is 0.");  | 
Determine if an individual is of legal voting age.
| 
 int myAge = 25; int votingAge = 18; 
 if (myAge >= votingAge) { System.out.println(“Old enough to vote!”); } else { System.out.println(“Not old enough to vote.”); }  | 
int 
if 
 } 
 }  |