Java Basics Review (2)

Source: Internet
Author: User

There are only two types of Java: underlying type, reference type

8 Basic type: byte short int long float double char Boolean, where byte type takes value range " -2^7~2^7-1", Short type

The value range is " -2^15~2^15-1", and the int type takes the value range " -2^31~2^31-1"

Defines a long type, habitually after the number plus L

Defines the float type and habitually adds F after the number

☆ Forced Conversion syntax
Small type variable name = (small type) large type value.

There may be an overflow phenomenon

Operators: Arithmetic operators, logical operators, relational operators, assignment operators, trinocular operators

There are only 3 types of code structures in Java: branching, sequential, and looping structures

Add: + can be a stitching symbol

Branch structure: If-else switch-case

switch (integral type) {
Case value 1: expression 1;
Case value 2: Expression 2;
Case Value 3: Expression 3;
....
}


★ If a branch is satisfied, the subsequent branch will be executed even if it is not satisfied.
Case value 1 is satisfied, expression 1 executes,
Case value 2, value 3 even if not satisfied, expression 1, expression 2 will also be executed.

The Break keyword
You need to use the break keyword under a specific (satisfied) branch structure.

Default keyword
At the end of the Switch-case branch, the default branch operation is added.
If all branches above default are not satisfied,
The code in the default will be executed.

Only integer, enum, in switch ().

Three elements of the loop:

Declaration initialization of variables, condition control, conditional judgment

Loop structure: While, for, Do-while

The Break keyword
Break: Exit, interrupt.
Used in a loop, expressed as exiting the current loop.

Continue: Skip this cycle

Two-dimensional loops: There are rows and columns when you think of 2 cycles

Second:for () {
First:for () {
break;//will only exit the first layer loop
Break second;//jumps directly out of the two-layer loop.
}
}

Java Basics Review (2)

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.