What are the operators of Java
This article is mainly about "what are the operators of Java". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the operators of Java"?
I. operator
1. Arithmetic operator
+ addition
-subtraction
* multiplication
/ division (division of integers can only get the result of integers. In order to get a decimal, one party involved in the operation must be a decimal)
% surplus
+ + self-increasing
-self-subtraction
Used alone: + and-have the same effect in front of and after the variable. All allow variables to increase or decrease.
Participate in the operation to use:
If + + or-is placed in front of the variable, it is self-increasing or self-decreasing before assigning a value.
If + + or-is placed after the variable, it is used with the original value first. And then increase or subtract.
Sample code
two。 Characters participate in + sign operation
When the character participates in the operation, the corresponding code table value is used for the operation.
'A' 65'a'97'0' 48
Data type conversion rules when different data types participate in the operation
Byte, short, char- > int- > long- > float- > double
Sample code
3. String participates in + sign operation
A string concatenated with a + sign with any data type will form a new string
The string is in front of it, and what we do is string concatenation.
The string is at the back, do the previous operation first, and then concatenate with the string
Sample code
4. Assignment operator
= assignment
+ = perform addition operation and then assign a value
-= subtract and then assign a value
* = perform multiplication and then assign a value
/ = divide and then assign a value
% = take the remainder and then assign the value
Sample code
5. Comparison (relational) operator
Greater than >
Less than =
Less than or equal to