Java Foundation Chapter III

Source: Internet
Author: User

First, basic if structure

1. Flowchart

Input/Output

Judging and branching

Process Line

1.1 Simple if condition to judge

if ( expression ) {

                                 // expression is true , execute the code in {}

}

1.2 Simple if condition to judge

if ( expression ) {

// expression is true , execute here

}else{

                                      // expression is false , this line here

}

Description: If the If or else is followed by, and there is only one line of code, {} can be omitted, but it is not recommended to omit

Second, logical operators

&& Logic and (press shift+7)--and (and, at the same time)

Multiple conditions, 1 are false, if () all false, multiple conditions are true at the same time, if () is true

                       || (Press shift+ to enter the above |) -or (OR)

Multiple conditions, as long as 1 are true, if () all is true

                      ! (in English state)--Take the inverse not equal to! =

determine if strings are equal  

A , case-sensitive: password

String Variables . equals ( value of string or string variable )

B , Case insensitive: Verification Code

String Variables . Equalsignorecase ( value of string or string variable )

How do I break down numbers in bits, 10, hundred, thousand? "P47"

Int digit = number% 10//decomposition get single digit

Int 10 bit = number/10 10//decomposition get 10 digits

Int hundred = number/100% 10//decomposition to get the number of hundred

INT thousand = number/1000% 10//Decomposition get thousand

Third, multiple if structure

if ( condition 1) {

                              // code block

}else if ( condition 2) {

                              // code block

}else if ( condition N) {

                              // code block

} else{

                              // code block

}

Description: An else if can have multiple, sequential requirements on the number range

in the I f Input String--if ( variable name . Equals (" string ")) {}

Iv. Nested IF structures

if ( condition 1) {

                         // code block

I f ( condition 1-1) {

}

Description: The if structure can be a if , If...else , multiple if and other structures

} else{

can be for if , If...else , multiple if and other structures

}

Java Foundation Chapter 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.