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