Operator ( assignment, arithmetic, relationship, logic,+ join, trinocular)
1) Assignment operator =
In Java, the assignment is performed using an equal sign (=), which assigns the right value to the left variable.
For example: int a = 10; String str = "ABCD";
Extended Assignment Operators + =,-=, *=,/=
For example: int a = 10; A + = 10; ----> I.E. A = a + 10;
2) Arithmetic operators + 、-、 *,/,%, + + 、--
The preceding 5 species are addition, subtraction, multiplication, division, and redundancy (modulo) operations.
Emphasis is on the back of the + + (self-increment) 、--(self-subtraction)
+ + increment operation, add 1 per self, for example: int i = 10; i++; I---->11
--Self-subtraction operation, minus 1 per self, for example: int i = 10; i--; I---->9
The above is used alone, but in conjunction with other variables, it is divided into 2 kinds:
① before + + (or before-)
int i= 10; int a = ++i;
In this case, the value after I plus 1 is computed, and then the value is assigned to the expression ++i, the value of the expression is then assigned to the preceding variable a,i = one, a = one; before--and this algorithm.
② after + + (or later--)
int i = 10; int a = i++;
In this case, after + +, the value of I is assigned to the expression i++, then I plus 1, the last expression value is assigned to the variable a,a = ten, i = 11;
Case 3:
650) this.width=650; "Title=" UR (5j0s1 ' ic9.png "src=" http://s3.51cto.com/wyfs02/M01/6C/B6/wKiom1VQX2_ Iljusaae6sv0jxf0566.jpg "alt=" Wkiom1vqx2_iljusaae6sv0jxf0566.jpg "/>
Case 4:
650) this.width=650; "title=" 4b.png "src=" http://s3.51cto.com/wyfs02/M02/6C/B1/wKioL1VQYQfCBZoJAAEA6TQjQ0Q214.jpg "alt=" Wkiol1vqyqfcbzojaaea6tqjq0q214.jpg "/>
3) Relational operators >, <, >=, <=, = =,! =
The return result of the relational operator is Boolean, that is, the relationship is true or not (false);
4) Logical Operators && (short circuit and), | | (short circuit or),! Non-
Both sides of the logical operator are boolean-typed, and the returned result is also of type Boolean.
&& (short circuit and): Both sides need to be established, the overall expression is established.
For example, to buy a car in Beijing, need 5 years of social security and have 5 years of tax proof, indispensable.
|| (Short circuit or): As long as the two sides have been established, the overall expression is established.
For example: Go to a restaurant, check out using cash or credit card, just one way to pay.
! (non): Non-operation, is the negation,!true is False,!false is true.
650) this.width=650; "style=" width:559px;height:176px; "title=" Cc.png "src=" http://s3.51cto.com/wyfs02/M02/6C/B6/ Wkiom1vqx-qdy8_paaefpbwjhsi368.jpg "width=" 743 "height=" 282 "alt=" wkiom1vqx-qdy8_paaefpbwjhsi368.jpg "/>
About the short circuit logic:
For ' && ',
When the expression on the left is false, the expression on the right is not judged, because the final result must be false, regardless of the value of the expression on the right.
For ' | | ',
When the expression on the left is true, the expression on the right is not judged, because the final result must be true regardless of the value of the right expression.
Case 5:
650) this.width=650; "title=" 5.png "src=" Http://s3.51cto.com/wyfs02/M00/6C/B6/wKiom1VQYXuz7T8HAAFtzQBTHRw610.jpg " alt= "Wkiom1vqyxuz7t8haaftzqbthrw610.jpg"/>
5) connection Operation +
In Java, there is a + connection between pure numbers, which means adding operations.
When a string "" occurs, + is the connector operation, which is no longer an addition operation.
Case 6:
650) this.width=650; "title=" 6.png "src=" Http://s3.51cto.com/wyfs02/M01/6C/B1/wKioL1VQZjDCFt5xAAIGtt5TGOI152.jpg " alt= "Wkiol1vqzjdcft5xaaigtt5tgoi152.jpg"/>
6) Three mesh operator
Syntax: type variable = Boolean expression? Result 1: Result 2;
Operation: When the Boolean expression is set, the value of the variable evaluates to 1, the value of the variable evaluates to 2.
Case 7:
650) this.width=650; "title=" 7rd.png "src=" Http://s3.51cto.com/wyfs02/M02/6C/B6/wKiom1VQZP6js_ S0aagdlb4nq-e828.jpg "alt=" Wkiom1vqzp6js_s0aagdlb4nq-e828.jpg "/>
This article is from "Forever Young" blog, please be sure to keep this source http://kingkongzhao.blog.51cto.com/6319491/1650294
Java Basic Learning Notes--5 (operator)