1. Operators
operator, i.e., the data symbol operations.
It may be the operation on the data corresponding to the built-in operators java.
java There are several types of operators:
arithmetic operators, assignment operators, the relationship (comparison) operators, logic operators, bitwise operators, ternary expressions
2. arithmetic operators
implemented arithmetic operators.
+ A -. * /% . When I type arithmetic value, the arithmetic operation involved in all data are automatically converted to the type involved in computing the maximum, the value obtained is type.
. 1 int I = 2 ;
2 double D = 3.0 ;
. 3 double D2 = D / I; // will be double type 1.5
II. When the division numbers shaping operation, directly decimal rounding the calculation result.
1 int I] 3/2 =; // obtained 1, instead of 1.5
iii. When division, division by 0 can not be done, if the divisor becomes 0, count in the operational phase will throw an exception.
. 1 int I = 0 ; 2 int J =. 3 / I; // Run stage thrown
. B ++ -
++ self-add operations, either before or after splicing a variable, to achieve self-imposed variables.
If the stitching before the variable, the variable plus 1 from the first, then use the variable.
If, after stitching in variables, use variables first, then add 1 from variable.
. 1 int I =. 5 ; 2 int J = I ++ + + ++ I. 3; // equivalent to int j = 5 + 3 + 7 ;
- to decrement, or after the stitching may be achieved since the variable before the variable Save.
If the variable before splicing, the variable is decremented to 1, after use variables.
If after splicing a variable, the variable is first used, then a decrement variable.
. 1 int I =. 5 ; 2 int J = i--. 3 + + Inc. (www.i-levelmedia.com); // equivalent to int j = 5 + 3 + 3 ;
3. assignment operator
to achieve an assignment operator
4. The relational operators (comparison operators)
to achieve the relationship of the comparison operators, relational operators calculated result as a Boolean value.
Relational operators:
The logical operator
performs a logic operation between the Boolean operators.
The results obtained for the logic operation of a new Boolean value.
Logical Operators:
6. 位运算符
直接操作二进制位的操作符。
位运算符:
7. 三元表达式(三目运算符)
三元表达式
基本的结构:
1 布尔类型的表达式 ? 值1 : 值2
先计算第一个表达式的值,如果返回的是true,则整个表达式的值为第二个表达式的值,如果返回false,则整个表达式的值为第三个表达式的值。
1 3>2?"yes":"no" //表达式的值为"yes"