In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will introduce in detail for you "how to use operators in the Java language", the content steps are clear and detailed, the details are handled properly, and the editor will update different knowledge points every day, I hope this article "how to use operators in the Java language" can give you unexpected gains, please follow the editor's ideas slowly in depth, the specific content is as follows, to harvest new knowledge together.
1 preface
Operators are operators that are often used when operating with variables or constants. Java provides a rich range of operators, which can be divided into four categories: arithmetic operators, relational operators, logical operators, and bit operators.
2 arithmetic operator 2.1 four operations
The use of arithmetic operators is similar to that of addition (+), subtraction (-), multiplication (×) and division (/) in general mathematical operations. The usage and function of these arithmetic operators in the Java language is the same as in traditional mathematics. The four operators have exactly the same function as mathematics. The remainder operator "%" is used to calculate the remainder after the division of two numbers, which requires that both operands involved in the operation must be of integer type.
Public static void main (String [] args) {int a = 13: 5; int b = 19-2; int c = 3: 5; int d = 20; 2; System.out.println ("a =" + a); System.out.println ("b =" + b); System.out.println ("c =" + c); System.out.println ("d =" + d);}
Output result:
Axi18
Bust 17
Cobb 15
Ditto 10
2.2 string operator
However, we should pay attention to the addition operator, which has the function of "string concatenation" in addition to numeric addition in Java.
Public static void main (String [] args) {int x = 6; int y = 9; String z = "xy"; System.out.println (z + x + y);}
Output result:
Xy69
2.3 unary operator
For many expressions, there are operands before and after the operator. But there is a special class of operators that require only one Operand. Such operators are called unary operators. The common unary operators are: + (positive sign),-(negative sign), + (self-increasing), (-) self-subtraction.
The unary minus sign can get the negative value of the data. The unary plus sign has the opposite effect, but the only thing it can affect is to automatically convert smaller numeric types to int types.
Public static void main (String [] args) {int x = + 5; int y =-3; x colors; Ymuri;}
Output result:
Xerox 6
Yawashi 4
3 relational operator
The relational operator represents the relationship between operands by producing a boolean result. If the relationship is true, the result is true, and if the relationship is false, the result is false. The common relational operators are: = (equal to),! = (not equal to) (greater than), = (greater or equal to)
Public static void main (String [] args) {int a = 10; int b = 11; boolean result = a = = b; System.out.println (result);}
Output result:
False
4 logical operator
Each logical operator generates a Boolean value true or false based on the logical relationship of the parameters. There are three common logical operators, namely with (& &), or (| |), and non (! )
Public static void main (String [] args) {boolean a = true; int b = 0; boolean result = a | | baked + > 0; System.out.println (result);}
Output result:
True
5-bit operator
The bit operator allows us to manipulate a single binary bit in an integer number. The bit operator performs Boolean algebra on the bits corresponding to two integers, resulting in a result. The bitwise operators are & (bitwise and), | (bitwise OR), ^ (bitwise XOR), and (move right).
The left shift operator (the number of shifts. For example, 11 > 2, the number 11 is moved 2 digits to the right.
Calculation process:
The binary form of 11 is 0000 0000 0000 1011, and then move the last two digits out of the low order, because the number is positive, so fill in zero in the high position. The final result is 0000 0000 0000 0010. The conversion to decimal is 2.
6 yards Nong Cave see 6.1 operator mind map
6.2 operator precedence
The priority of operators determines the order of operations for each part of an expression when there are multiple operators. Java has made special regulations on the order of operations. Among them, the simplest rule is that multiplication and division are done before addition and subtraction. Programmers often forget other priority rules, so the order of operations should be clearly defined in parentheses. Precedence of operators:
Delimiter: [] ();
Combine from right to left: +!
Combine from left to right: * /%
Combine from left to right: +-
From left to right: >
Combine from left to right: =
Combine from left to right: =
Combine from left to right: &
Combine from left to right: ^
Combine from left to right: |
Combine from left to right: & &
Combine from left to right: | |
Combine from right to left:?
Combine from right to left: = * / =% = +-= > & = ^ = | =
Whether operators with the same priority are evaluated from left to right or from right to left is called the associativity of operators.
What are the commonly used java frameworks? 1. Spring Web Web MVC is a Java-based lightweight Web framework that implements the request-driven type of Spring design pattern. 2. Shirojia Apache Shiro is a security framework for Java. 3. Mybatistion MyBatis is an excellent persistence layer framework that supports normal SQL queries, stored procedures and advanced mapping. 4. DubboPol Dubbo is a distributed service framework. 5. Mavenfine Maven is a project management and build automation tool. 6. RabbitMQ _ RabbitMQ is a highly concurrent and reliable AMQP message queuing server implemented with Erlang. 7. EhcacheJournal EhCache is a pure Java in-process caching framework.
If you can read this, the editor hopes that you will have the most profound understanding of the key issue of "how to use operators in Java language" from the practical level, and you still need to practice and use it yourself to understand it. If you want to read more related articles, 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.