Java_ Statement _ Basic Summary

Source: Internet
Author: User

Java programs are composed of statements. Statements are divided into:

1 declaration statements: usually used for declaring variables, arrays, and naming them, and sometimes assigning an initial value;

Ex:int A;

int a=0;

int [] b=new int[n];(N represents the number of elements in the array)

2 An assignment statement assigns a value to a variable after an operation;

ex:a=1+1;

3 conditional statements execute different two codes according to the conditions, and the structure is usually

if (judging condition) {

Executes the code in this case when the judging condition is true

}else{

Execute the code in this case when the judging condition is false

};

4 loop statements repeatedly execute code as long as the condition is true;

EX while (a<5) {

a++;

}

for (int a=0;a<5;a++) {

a++;

} (where a<5 is the condition that jumps out of the loop)

You can also use continue to skip a loop and jump out of the loop with a break.

5 Call and return statements;

Java_ Statement _ Basic Summary

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.