Java Branching and looping

Source: Internet
Author: User

First, the underlying data type (four classes of eight): cannot be null
Integer type
BYTE----2 of 8 square
Short----2 of the 16-time Square
int----2 of the 32-time Square
Long----2 of the 64-time Square
Floating point Type
FLOAT----4 x
Double---8 bytes
Boolean type
Boolean (True, False)
Character type
Char (can be a letter, or it can be a Chinese character)

int a = 5;
Save All to Stack
Reference type: String s = "abc";
All the classes
All the arrays
All the interfaces

Second, branch
if (expression _ Boolean value) {
...
}

if (expression _ Boolean value) {
...
} else {
...
}

if (expression _ Boolean value) {
...
} else if (expression _ Boolean value) {
...
}

if (expression _ Boolean value) {
...
} else if (expression _ Boolean value) {
...
} else {
...
}

int a = 2;
Switch (a) {
Case 1
...
Break
Case 3
...
Break
Case 5
...
Break

Default
...
}

Branching and looping
if () {
}

if () {
}else{
}

if () {
}else if () {
}

if () {
}else if () {
}else

Switch (a) {
Case 1
...
Break

Case 2
...
Break

Case 3
...
Break
}

Iii. the difference between if and switch

Cycle
for (int i=0; i<10; i++) {
...
}

while (loop condition) {
}

do{
}while (); This cycle loops at least once.

Java Branching and looping

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.