Variable: strongly typed
Local variables:
1. Assign values first, then use
2. Scope of action: Starting from the definition, to the end of the block of code
3. Duplicate naming is not allowed in coincident range
Data type (basic type in 8)
BYTE 1b-128~127
Short 2b-32768~32767
int 4 b
Long 8B L or L
Float 4 B F or F
Double 8B D or D does not add
Boolean 1 B True False
Char 2B ' A '
Object type
String "hehe"
Forced conversions
int a= (int) 12.5;
Automatic type Promotion
A b look there is no double ===>double
There is no float====>float
Is there a long ===>long
There's no ====>int.
Operator:
= assignment operator int a=2;
+ - * / %
+ = = *=/=%= a>b?a:b
+ +--a++ ++a
> < >= <=! = = =
Simple program Flow:
Program Flow
Sequential process
Conditional branching Process
if (Boolean expression) {}
if () {}else{}
switch (expression) {byte int short char String (1.7)
Case value 1;break;
Case value 2;
....
Default
}
Cycle
while (Boolean type) {} 0-n
do{Loop Body}while (Boolean type) 1-n
For (initialization of the loop variable; boolean type expression; change of loop variable) {}
Break jumps out of the loop
Continue jump out of this cycle
Java variables && Simple program flow && loops