Chapter 4
Operators, expressions, and Flow Control
Variable is used to record variable data.
Java variables must be declared and initialized before use.
The member variables are declared in the class definition.
Create related member variables while creating objects
After a member variable is created, the system automatically initializes it by default and explicitly initializes it. The member variables are attached to objects.
& | OR = value assignment operator
Branch statement
If else
Int I;
Switch (I) // The I in case must be a numerical value and cannot be a value range.
{If the value range is required, the entire table can be divided by logarithm.
Case:
Operation;
Break;
Case:
Operation;
Break;
Default:
Operation;
Break;
}
}
The switch expression must return int, byte, Char, and short values;
The value required by the case clause must be a constant.
Break is used to exit the switch statement block after executing a case Branch.
Loop statement
For
While
Do/while
The break statement is used to terminate the execution of a statement block and terminate immediately.
The coninue language is used to skip one execution of a loop statement block.
Immediately jump out of this statement block and continue the loop