Operators are divided into operations and characters.
Operation : is a behavior that obtains new quantities by means of a known amount of possible combinations.
symbol : ancient times, the symbol is the communication and the secret of God's pattern, so the symbol is not casually scribble, so the so-called "drawn Taoist charm do not know the body, anti-provoke ghosts and spirits laugh, painting characters know, surprised to the ghost called" the saying. Drawn Taoist charm Hundreds of methods, some to pinch to save the spirit of the essay, and some to step the gang, read the spell ...
Cough, know the origin of the operator, so the program is not well written, just look at the operator good bad! 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0019.gif "alt=" J_0019.gif "/>
======================, I'm the split line, June ===================.
Of course, it's all up to me, what is the operator in Java?
In fact, similar to the math in mathematics, according to the priority of operations , look at the following table:
|
Order |
Operator |
| 1
|
brackets, such as () and [ ] |
| 2
|
unary operator , such as -, + + 、--and! |
| 3
|
arithmetic operator , such as *,/,%, +, and- |
| 4
|
relational operator < span> |
| 5
|
logical operator , such as &&, | | |
| 6
|
and , such as ? :, =, *=,/=, + =, and -= |
Most of the symbols believe that you crossing all right? Of course there is a problem, please leave a message, haha
Below I briefly introduce a completely not novice still do not know a few symbols bar, if have 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0022.gif "alt=" J_0022.gif " /> Party, please pass quickly ...
Unary operators:
+ +: The value of the variable itself is basically +1.
public static void Main (string[] args) {int i = 5; int j = i++; + + in the back, so first execute j=i, then execute i++, after execution i=6,j=5; int k = ++j; + + in front, so first execute ++j, then execute k=j, after execution j=6,k=6; System.out.println (The value of "J" is: "+j); System.out.println (the value of "K" is: "+k); }
--: The same principle as + +, only becomes-1.
Arithmetic operators:
*: Indicates multiplication.
int i = 12; int j = 5; int k = I*j; The value of K is 60
/: Indicates division.
int i = 12; int j = 5; int k = i/j; The value of K is 2
Note: Because i/j are integers, the results of the calculation do not contain fractional parts. Even if k is defined as a double type, the result is 2.0.
%: Indicates the remainder is obtained. The remainder you know, I don't have to say more.
int i = 13; int j = 5; int k = I%j; The value of K is 3
Relational operators:
! =: Indicates not equal. Never write "<>".
= =: indicates equality. Never use only one "=".
Logical operators:
Actually "! "is a logical operator that represents the opposite result.
With regard to logical operators, you can understand them through an example.
Remember when you first went to college, a roommate swore "to find a rich && beautiful sister as a girlfriend", the results of two years have not found satisfaction, then he lowered the request "to find a rich | | Beautiful sister as a girlfriend ", the results of two years later still did not find satisfaction, and finally he lowered the request again" to find a girlfriend, as long as ! A man is fine. "
Haha, read it!!! 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0028.gif "alt=" J_0028.gif "/>
Assignment operators:
=: Indicates that the result of the right expression is placed in the left variable, so the left can only be a variable, not an expression.
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/03/A6/wKiom1mfzJ2gqOnAAAAIu-0uOe8543.png "title=" 11. PNG "alt=" Wkiom1mfzj2gqonaaaaiu-0uoe8543.png "/>
+ =: After adding the right data to the left variable, assign the result to the left variable.
int i = 13; i + = 3; The result of I is 16.
Other functions (-=,*=, etc.) are the same.
Conditional operators:
?:: This is a three-mesh operator (corresponding to three expressions).
int i = 13; Change the value of I to 5 and see what the result of STR is.//I>10 the value of STR is "yes", otherwise "no" String str = i > 10? "Yes": "No";
Although the operator seems to have so many symbols, in fact, we are often used in the coding process, but also relatively simple to use, do not have to deliberately memorize.
OK, here's what this article is about. 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0042.gif "alt=" J_0042.gif "/>
"Software Thinking" blog address:51CTO,Blog Park, interested small partners can go to see the relevant other blog posts.
This article is from the "Software Thinking" blog, please be sure to keep this source http://softi.blog.51cto.com/13093971/1959316
Java from getting started to giving up: operators