Home >Java >javaTutorial >How to use operators in JAVA
Operator: Common ±*/etc.
Expression: The operators are connected in accordance with java Syntax formula, such as a b
arithmetic operator: - * / %
Note: To get decimals, there must be floating point numbers in it Participate
When printing, char and int are converted according to ASCII code
The " " of string is the string concatenation operator, that is, splicing
Assignment operator: a=10 , don’t say that a is equal to 10, but say that 10 is assigned to the variable a
Note: When performing =, -=, *=, /=, %= operations, type conversion will be automatically forced
is, –
Note: The result of a single i is the same as i, but there is a difference when assigning values: j=i becomes j=i,i;j = i becomes i, j=i
Relational operators: ==,! =, >, >=,
Logical operators:&, |, ^,!
, the output is a Boolean value
Short-circuit logical operators: &&, ||
, the result is the same as above. However, if the front of && is false, the following will not be executed; if the front of || is true, the following will not be executed (short-circuit effect)
Format : Relational expression? Relationship 1: Relationship 2
Scanner usage steps: 1. Guide the package; 2. Create the object; 3. Receive data.
The above is the detailed content of How to use operators in JAVA. For more information, please follow other related articles on the PHP Chinese website!