One:
Block scope
Block (i.e. compound statement): Refers to a number of simple Java statements enclosed by a pair of curly braces. The block determines the scope of the variable, and one block can be nested within another block, as follows:
1 Public classprint_in {2 Public Static voidMain (string[] args) {3 inta=2;4 {5 intA=3;6 intB=3;7 }8 }9}
Note: In a block, define a variable, can not be nested in the block in the definition of the same variable, if the definition will error.
Two: if statement
The IF statement in Java is different from the IF statement in Python, Python can be used as an array, string, dictionary and so on to serve as a condition, but in Java can only use the expression directly can judge the Boolean value, can make judgments, otherwise it will error.
1 Public classprint_in {2 Public Static voidMain (string[] args) {3 inta=2;4 intV=4;5 if(a<4){6System.out.println ("OK");7}Else {8System.out.println ("Bad");9 }Ten } One}
Java Control flow