The compound assignment operators are: + =,-=, *=,/=,%=, >=, >>>=, &=, ^=, and | =The simple assignment operator is =;The code is as follows:public class Example009 {public static void main (string[] args) {short x = 1;int X1 = 1;int i = 123456;x + =
This is the problem in the development today, although not very big, but still spent a little time to ponder.Yes, that's good. Read the source code first Short value=2; value-=2;The source code is like the above, I write the time because of the
Question: i + = j is just the shorthand for i = i + j?Answer: not also! Look at the following program:int i = 5; long j = 8+ = j; // can be compiled and the result is correct i = i + j; // cannot compile, type conversion issuesIn fact, Java
How is the compound assignment operator + = computed ?, Value assignment operator
This article Reprinted from: http://tanlan.blog.51cto.com/3450625/1575936
Question:
short s1 = 1; s1 = s1 + 1;
What's wrong?
short s1 = 1; s1 +=1;
What's wrong?
At
Let's look at an example:// Add a declaration while I = 0) { i>>>=1; }Add a line of code at the Add Declaration to make the above loop a dead loopLong i =-1;or int =-1;Oh, no!!!Try short i =-1;What's up?Dead cycle!!!!Since there's been a
The compound assignment operators include + =,-=, * =,/=, % =, >=, & =, ^ =, | =.
The following uses + = as an example.
A + = expression (1)
It is equivalent:
A = a + expression (2)
However, there is a difference here. (1) expression A (such as the
Priority level
operator
description
examples
of associativity
1
()[]-.::++--
The parentheses operator that adjusts the precedenceArray Subscript access operatorTo access a member's operator by
Priority Level
operator
Description
Example
Binding Nature
1
()[]-.::++--
The parentheses operator that adjusts the precedenceArray Subscript access operatorTo access a member's operator by pointing to the
Just occasionally saw Justjavac write Java FAQ-Dora (i) and Java FAQ-Dora (ii). It mentions the two traps of the Java compound assignment operator: 1 The compound assignment operator has the semantics of coercion type conversion; 2) = = The left
Priority Level
operator
Description
Example
Binding Nature
1
()[]-.::++--
The parentheses operator that adjusts the precedenceArray Subscript access operatorTo access a member's operator by pointing to the
Priority Level
operator
Description
Example
Binding Nature
1
()[]-.::++--
The parentheses operator that adjusts the precedenceArray Subscript access operatorTo access a member's operator by pointing to the
Priority Level
operator
Description
Example
combination of
1
()[]->.::++--
Bracket operator for adjusting precedenceArray Subscript access operatorTo access a member's operator by pointing to an object's
"operator"at the time of the operation, if the closing parenthesis we know what to do first, then if there is no parentheses, arithmetic operators, relational operators, logical operators, bitwise operators, assignment operators, + + 、--operators,
Operator precedence from high to low
Priority Level
operator
Description
Example
Binding Nature
1
()[]-.::++--
The parentheses operator that adjusts the precedenceArray Subscript access
Priority level
Operator
Describe
Example
Binding nature
1
() [] -> . :: + + --
Array subscript access operator operator that accesses a member through a pointer to an object operator that accesses
Priority Level
operator
Description
Example
combination of
1
()[]->.::++--
Bracket operator for adjusting precedenceArray Subscript access operatorTo access a member's operator by pointing to an object's pointerTo
Priority Level
operator
Description
Example
combination of
1
()[]->.::++--
Bracket operator for adjusting precedenceArray Subscript access operatorTo access a member's operator by pointing to an object's pointerTo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.