Java basic data type conversion and operators, java Operators
The last time we talked about the basic data types in Java, today we will talk about the basic data type conversion in Java and the operators in Java
Basic data type conversion
Java can transform from any basic data type to an external Basic Data Type
Note: (boolean) data types cannot be converted to other data types.
Conversion is divided into default conversion and forced conversion.
Integer, complex, and floating point data are converted to each other in hybrid operations. The conversion follows the following principles:
(1) small data types are converted to large data types by default; data types are sorted by capacity:
Byte, short, char,-> int-> long-> float-> double;
Byte, short, and char are not converted to each other. They are first converted to the int type during calculation;
(2) When a data type with a large capacity is converted to a data type with a small capacity, it must be called a forced conversion character,
However, it may cause lower precision or overflow () (overflow occurs when double is converted to float;
(3) when there are multiple types of data mixed operations, the system will first automatically convert all the data into the data type with the largest capacity, and then perform the calculation;
(4) real number constants; Float Type: double by default; Integer constants: int by default;
Java program format;
(1) braces are aligned;
(2) If {indentation, Tab/Shift + Tab;
(3) adding blank lines between program blocks
(4) add spaces between side-by-side statements
(5) add spaces on both sides of the operator-specific conditions
(6) {leading space
(7) paired Programming
Operator
Java supports the following operators:
(1) Arithmetic Operators: +,-, *,/(entire division), %, ++ ,--;
(2) Relational operators: >,<,>=, <=, == ,! =;
(3) logical operators :! , &, |, &, |, (Short circuit and/or)
(4) bitwise operators: &, |, ^ (XOR ),~ (Reverse), >>,<<>>> (shifts right unsigned, fills with 0 );
(5) value assignment operator; =;
(6) extended value assignment operator; + =,-=, * =,/=,
(7) String concatenation operator; +;
(8) three-object operator X? Y: Z;
Value assignment operator and extended value assignment operator