Today we're going to talk about process control in Java.
Let's start by talking about the SELECT statement.
There are two types of SELECT statements: 1, if statements. 2, switch statement;
The IF statement is divided into three kinds: if, if else, if elseif else.
The conditional statements in Java are consistent with C + +, and there is not much difference.
Simple If statement example code:
/**IF Conditional Statement "Sample code * Function: Enter three numbers, output maximum */Import Java.util.Scanner;PublicClass Program {PublicStaticvoid Main (String [] args) {int num1,num2,num3,Max Scanner input =New Scanner (system.in); System.out.println ( "Please enter first number:"); Num1=input.nextint (); System.out. println ( "Please enter a second number:"); Num2=input.nextint (); System.out. println ( "Please enter third number:"); Num3=input.nextint (); MAX=NUM1; if (Num2>max) {MAX=NUM2;} if (Num3>max) {MAX=NUM3;} System.out. println ( "max=" +max); input.< Span class= "hljs-built_in" >close (); }}
Note: if: There is no relationship between a single branch structure multiple if, it is executed sequentially. The
if else else must be related to its nearest if.
If ElseIf else: there is a jumping off phenomenon.
Thank you for your support, and your support will encourage me to continue to create!
/span>
Process Control statements on the Java Basic Road (iii)----