In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you the "sample analysis of java operators and expressions", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "sample analysis of java operators and expressions" this article.
Operators are essential knowledge points in Java learning. Java provides a wealth of operators, such as arithmetic operators, relational operators, logical operators, bit operators, and so on. The expression of Java is a formula that conforms to the Java rules connected by operators. The precedence of the operator determines the order in which the operations in the expression are performed. When writing the program, try to use the parenthesis () operation symbol to achieve the desired operation order, so as to avoid difficult to read or ambiguous calculation order. The associativity of operators determines the order of operators of the same level juxtaposed.
Arithmetic operator
1. Add and subtract operators: +,-
The addition and subtraction operators are binocular operators; the combination direction of the addition and subtraction operators is from left to right; the operands of the addition and subtraction operators are integer or floating-point data, and the priority of the addition and subtraction operators is level 4.
2. Multiplication, division and remainder operators: *, /,%
The above operators are binocular operators, the combination direction is from left to right, and the operands of the multiplication, division, and remainder operators are integer or floating-point data. The priority of the operator is level 3.
3. Arithmetic expression
Expressions that conform to java grammatical rules connected by arithmetic symbols and parentheses are called arithmetic expressions.
4. Self-increasing and self-decreasing operator: +,--
Is a unary operator that can be placed before or after an Operand. The Operand must be an integer or floating point variable. The function is to increase or subtract 1 from the value of the variable, such as:
+ + x (--x) means to increase (decrease) the value of x by 1 before using x.
After using x, increase (decrease) the value of x by 1.
Operation precision
The order of precision from "low" to "high" is:
Byte short char int long float double
Java uses the following calculation precision rules when evaluating the value of an arithmetic expression:
1. If there is a double-precision floating-point number (double data) in the expression, the operation is performed as double-precision.
2. If the highest precision in the expression is a single-precision floating-point number (float data), the operation is performed according to single-precision.
3. If the highest precision in the expression is a long integer, the operation is performed according to the long precision.
4. If the highest precision in the expression is lower than the int integer, the operation is performed according to the int precision.
Relational operator
Relational operators are binocular operators that are used to compare the relationship between two values. The result of the relational operator is of Boolean type. When the relationship corresponding to the operator is established, the result is true, otherwise it is false.
Logical operator
Logical operators include: & &, | |!
Where & &, | | are binocular operators that implement logic and, logic OR.
! Implements a logical no for a unary operator.
The operands of logical operators must be Boolean data, and logical operators can be used to join relational expressions.
Bit operator
Bit operators are rarely used in real Java.
The bit operation is implemented on two integer data, that is, a new integer data is obtained by calculating the bits corresponding to the two integer data.
1. Bitwise and "operation
Bitwise and operator & are binocular operators.
2. Bitwise or "operation
The bitwise or operator: | is the binocular operator.
3. Bitwise non-"operation
The bitwise non operator: "~" is a unary operator.
4. Bitwise XOR operation
Bitwise XOR operator: ^ is a binocular operator
Other
1. Assignment operator and assignment expression: =
The assignment operator is a binocular operator, and the Operand on the left must be a variable, not a constant or expression.
The assignment operator has a lower priority, level 14, and combines right to left.
The value of the assignment expression is the value of the variable on the left side of "=".
Note: do not confuse the assignment operator "=" with the relational operator "=".
2. Instanceof operator
The instanceof operator is a binocular operator, and the Operand on the left is an object; on the right is a class. When the object on the left is an object created by the class or subclass on the right, the result of the operator operation is true, otherwise it is false.
The above is all the content of the article "sample Analysis of java operators and expressions". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.