When Java is in operation, there are conversions of data types, one of which is automatic type conversion, also known as implicit type conversion, which needs to meet certain conditions:
1. The two types are compatible, such as both integer types or numeric types
2. The scope of the destination type number is greater than the range of the source data
There is also a coercion type conversion, also known as a display type conversion, that sometimes occurs when truncation and narrowing, such as casting a decimal to an integer, discards the fractional portion.
All byte and short types are automatically converted to int when operating, and the result of two byte operations is an int rather than a byte type, and if there are operands in the expression long, the entire expression is promoted to a long type. That is, long if the expression has an operand of type float, the expression is promoted to float, and if the operand is of type double, the expression is promoted to type double.
There are four types of operators in Java, namely arithmetic operators, bitwise operators, relational operators, and logical operators.
Arithmetic operators: + 、-、 *,/,% (or the remainder), + + (increment or call to increase) 、--(decrement or call), + =,-=, *=,/=,%=; it is important to note that when the self-increment and decrement operations are used, the symbols are followed by the first operation, and the symbols are used after the first operation. When the division is performed, the result of the integer operation is to place the decimal digits. The% operation is not the same as C + +, which can also be used on decimals in Java.
Bitwise operators: The temporary phase is almost unused.
Relational operators:>, <, = =, >=, <=,! =; in Java, a = represents an assignment, and two = is equal to.
Logical Operators:&, |,! , &&, | |, ^, &=, |=, ^=, = =,! =,? :; where && and | | The difference between & and | Is that the former has a short circuit function. : Represents a three-mesh operation, or a ternary operation,? Is the logical expression before, and the result is true? And: The value between, otherwise take: the value after.
Learning Diary (v) Java operations