Java Chapter III Operators and conditional structure notes

Source: Internet
Author: User

One, save true or FALSE, use the Boolean variable
There are two values: True True
False false

Ii. accept input information from the console by creating a scanner
Scanner input New Scanner (system.in);
int age input.nextint ();//Receive int type
String Name=input.next ();//Receive Strin type

Third, relational operators
> < >= <= = = =!

Iv. the difference between = = and =
= comparison, = Assignment


V. Conditions of Judgment if
if (expression) {
Statement
}

When an expression is a true execution statement

The operators are divided into single-mesh operators, binocular operators, trinocular operators
Monocular operator:! ++ --

Binocular Operator: = +-*/% | | | & && = =

Trinocular operator:? : Example int sign= java>90?1:0;


Seven, logical operators
| & | | &&!
Priority order () >! > Arithmetic operator >&&>| | Assignment operator =
Multi-use () control priority

Eight, If-else
if (expression) {
Statement 1;

}else{
Statement 2;
}
When the expression is true, execute statement 1, when the expression is false, execute statement 2;


     if (condition 1) {
        statement 1;
     }else if (condition 2) {
        Statement 2
     }else if (condition 3) {
        Statement 3
     }else
        statement 4
     }

ten, swicth (expression) {
     case Value 1:
    statement 1;
    break;
    Case value 2:
    statement 2;
    break;

    default:
    Statement 3;
    break;
   }
    JDK versions above 1.7 or 1.7, the expression value can be string type;
    value cannot be the same;
    Break is the function of jumping out of the switch structure;


Xi. multiple if structures and switch structure use cases:
Multiple if judging interval value, switch judging equivalence

Java Chapter III Operators and conditional structure notes

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.