Java Basic Road (iii)----Process Control statements

Source: Internet
Author: User

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)----

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.