sixth chapter for loop syntax: for(initialize an expression; a conditional expression; a cyclic variable changes an expression) {//Loop Body} initialization expression: Used for the initial loop variable value condition expression: If true, the loop body is executed, otherwise the loop loop variable expression is exited: Control for the loop variable such as I++,i--Execution Order1. Initialize an expression (only once)2The conditional expression, if true, performs a third step, or exits the loop3. Loop Body4. Loop variable expression, execute the second step after execution, and loop in turn note: The three expression in the For loop can be omitted if the second expression is not written, then its result is true. Public Static voidMain (string[] args) {Scanner input=NewScanner (System.inch); System. out. println ("Please enter a number:"); intNUM1 =Input.nextint (); for(intI=1; i<= -; i++){ if(i%3==0) {System. out. println ("Flip"); Break; } if(i%5==0) {System. out. println ("Flop"); Break; } if(i%3==0&&i%5==0) {System. out. println ("flipflop"); Break; } } }
Java: Sixth chapter