Expressions in the Java language (basic sentences)
int x, y ; / / declare
int z = x + y; / / operation
if(true) {.. ; }/ / determine
while(true) {.. ; }/ / loop
Copy the code
- Classification of sentences
- The statement
- operation
- judge
- cycle
Java language variables
What does a variable mean
- Properties of objects are similar to, but not identical to, variables
- What types do variables have
- Instance variables (non-static properties of the class)
- Class variables (static properties of a class)
- Local variables (temporary properties declared inside methods)
- Method parameters (properties specified when declaring methods)
- When do you call it a property and when do you call it a variable
- When you talk about attributes, you don’t include local variables and parameters
- When you talk about variables, you can mean class properties, object properties, local variables, method parameters
Naming rules for variables
- Case sensitivity
- Variables declared as Car and declared as Car are two completely different variables
- Unlimited length
- Consists of Unicode characters and digits and must start with a character
- It can be declared as Abc123, but not as 1abc23
- Do not start with $or _
- Except for the first character, there is no requirement for subsequent characters and digits
- When declaring variables with only one word, use all lowercase
- Such as the car
- When declaring a variable with two or more words, the first character of the second word is capitalized
- Such as bigCar
- Consists of Unicode characters and digits and must start with a character
Java language operator
The operator | priority |
---|---|
The suffix | expr++ , expr– |
The prefix | ++expr, –expr, +expr, -expr, ~ , ! |
A multiple | *, /, % |
The cumulative | The +, – |
conversion | <<, >>, >>> |
Relationship between | < , > , <= , >= , instanceof |
equivalent | == , != |
Bitwise and | & |
The bitwise exclusive or | ^ |
Bitwise or | | |
Logic and | && |
Logic or | || |
Three yuan | expr? true:false |
distribution | =, + = – =, * = | = % =,,, & = ^ =, | =, <, < =, > > =, > > > = |