Home > Java > javaTutorial > What operators are there in java

What operators are there in java

百草
Release: 2024-01-29 14:58:56
Original
1360 people have browsed it

java operators: 1. Arithmetic operators; 2. Comparison operators; 3. Logical operators; 4. Bit operators; 5. Assignment operators; 6. Conditional operators; 7. Type conversion Operator; 8. String concatenation operator; 9. Increment and decrement operators; 10. Relational operator; 11. null operator; 12. Type test operator; 13. Bit test operator; 14. Suffix Increment and decrement operators; 15. Prefix increment and decrement operators; 16. Power operator; 17. Type coercion.

What operators are there in java

The operating system for this tutorial: Windows 10 system, DELL G3 computer.

Java operators are symbols used to perform arithmetic operations, comparison operations, logical operations and other operations. The following are commonly used operators in Java:

1. Arithmetic operators: are used to perform basic mathematical operations, including addition ( ), subtraction (-), multiplication (*), Divide (/) and find remainder (%).

2. Comparison operators: are used to compare the size relationship between two values, including greater than (>), less than (<), greater than or equal to (>=), less than Equals (<=).

3. Logical operators: are used to perform logical operations, including AND (&&), OR (||), NOT (!).

4. Bitwise operators: are used to operate on binary bits, including bitwise AND (&), bitwise OR (|), bitwise XOR (^), bitwise NOT (~ ).

5. Assignment operator: is used to assign values ​​to variables, including assignment (=), increment (), and decrement (--).

6. Conditional operator (ternary operator): is used to select one of two values ​​​​based on conditions, the format is Condition? Value 1: Value 2.

7. Type conversion operator: is used to convert one data type to another data type.

8. String connection operator ( ): is used to connect two strings.

9. Auto-increment and auto-decrement operators: and --.

10. Relational operator: instanceof, used to determine whether an object is an instance of a class or an instance of a subclass of the class.

11. Null operators: == and !=, used to compare whether an object is null.

12. Type test operator: instanceof, used to determine whether an object is an instance of a specific type or its subclass.

13. Bit test operators: &, |, ^, ~, <<, >>, >>>.

14. Suffix increment and decrement operators: Use the or -- operator to increment or decrement the variable.

15. Prefix increment and decrement operators: Use the or -- operator to increment or decrement the variable in the expression.

16. Power operator: Use ^ or ** operator to calculate the power of a number.

17. Type cast: Use () and the type name to convert a value to the specified type.

These operators are used in Java programs to perform various calculations and control flow operations. It should be noted that different operators have different precedence and associativity, which determines the order in which they are evaluated in an expression. For example, arithmetic operators have higher precedence than comparison operators, while assignment operators have lower precedence than arithmetic operators. Therefore, in complex expressions, parentheses are needed to explicitly specify the order of evaluation.

The above is the detailed content of What operators are there in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template