Source: http://www.imooc.com/code/1354
The operation of the If...else statement is one step more than an if statement: when the condition is true, the code block of the if part is executed, and if the condition is not true, the else part is entered. For example, if the test result is more than 90 points, reward an IPHONE 5S, or do 500 push-ups.
Grammar:
Execution process:
Such as:
Task
Try If...else ... Look at your age!
Please complete the code in the blank space in the editor and implement the function "if the age is greater than or equal to 18 years old, then prompt adulthood, otherwise prompt minors"
Operation Result:
1 Public classHelloWorld {2 Public Static voidMain (string[] args) {3 intAge=25;4 5 if(Age >= 18) {6SYSTEM.OUT.PRINTLN ("adult");7}Else {8System.out.println ("minors")); 9 }Ten } One}
Mu Net-android engineer first form the if...else of -4-2 Java conditional statement