Arithmetic operators
+ concatenated positive number of the added string
-phase reducing of the burden
* Multiply
/divide 10/3 = = "The highest precision in 32 operands is the INT
% Modulus (redundancy)
+ + self-increment
--Self-reduction
+ + and--only enough on the variable, not enough in the constanta = i++: First assigns the value of I to a, then self-increment 1 a = ++i; increment 1 First, then assign the value of I to aSpecial:1/0 Report Abnormal (run error) 1/0.0 Infinity (infinity) in Java 0.0 is not 0, but is infinitely close to 0 of the number 0.0/0.0 NaN (not a number) A = Nan if (a== A) is False (the only exception in Java that is not equal to itself)
Assignment operators:
=,+=,-=, *=,/=,%=
byte a = 3; A = a+5 error occurs: a+5 is an int type (Byte,short,char is automatically promoted to int when participating in the Operation) A + = 5; correct
Comparison operators
= = Whether the judgment is equal
>,<, >=, <=,!=
------> Run results are boolean values
> < <= >= can only be used between numbers
= = = can make any type
Logical operations
& Logic and Effect equals and and true results are true
| Logical or effect equivalent to or or as long as there is a true result of true
&& logical double with effect equivalent to and and
|| Logical double or effect equivalent to or or
^ XOR or
! Logical Non-
① The result of a logical operation is a Boolean value
② participate in logical operations are Boolean values (or expressions that result in a Boolean value)
One dollar
int i = 1; i++
Two Yuan
3 + 4
Expression: A calculation made up of some constant variable operators
int a = 10;
Double d = 3.14;
A + D * (110-100)
-----> Write the purpose of such expressions? Want to get a result value
The type of the value of the expression is the highest precision in the entire expression
Ternary operations
Format:
X? Y:z
① the X? Y:z as an expression----"focus on the result value
②x can be a Boolean value, or an expression with a result value of Boolean type;
Both ③y and Z are the result values of the entire expression.
Y or Z may be a constant value or a variable, or it may be an expression
④ if the value of X is true, then the value of the entire ternary operation expression is the value of y;
If the value of X is False, then the value of the entire ternary expression is the value of Z;
⑤? r = X? Y:z----> Y Z must be of the same type
You can use parentheses in Java for precedence, so you don't have to worry about priorities.
SELECT statement
①
if (condition) {
If the value of the condition is true, all the code in this pair of curly braces is executed once, otherwise it is not executed
}
if (condition) {
If the value of the condition is true, all the code in this pair of curly braces is executed once, otherwise it is not executed
}else{
If the value of the condition is false, all the code in this pair of curly braces is executed once, otherwise it is not executed
}
if (condition 1) {
If the value of the condition is true, all the code in this pair of curly braces is executed once, otherwise it is not executed
}else if (condition 2) {
If the value of the condition is true, all the code in this pair of curly braces is executed once, otherwise it is not executed
}else if (condition 3) {
If the value of the condition is true, all the code in this pair of curly braces is executed once, otherwise it is not executed
}else{
}
---------------------------------------------
②switch
Switch (variable) {
Possible value of case variable 1:
function execution statement;
Break
Possible value of case variable 2:
function execution statement;
Break
....
Default
function execution statement;
Break
}
Precautions:
The ① execution order is matched from the first case found in switch,
If the code is executed when it is found, the complete switch is terminated when the execution is completed.
If all the case does not match, execute the default
The order of multiple case and default in ②switch can be arbitrary;
However, in the actual development of the recommended installation case value of the size of the arrangement, and then default written in the last;
③break; From the beginning of the match, the other case to the first break does not judge but executes all the function execution statements, and if there is no break, then the entire switch ends
The value type after ④case must be the same as the type of the variable in Swtich ()
What types of variables are supported in the () ⑤switch?
Java5 before byte short char int
Java5 Start Enumeration (enum) at the time of the Polygon object
Java7 Start String
Java Foundation 2_ operator, select statement