Home > Back-end >  Java operator.
Java operator.

Time:02-18

A, arithmetic operators



Note: since the increase (from) reduction in front and behind the difference:
+ + y (y) : y values from the first increase since minus 1, and then used in the current expression y,
Y++ (y) : first in the current expressions using the value of y, then the value of y on the down (since) 1,

In addition to note

Two integer division, divisor cannot be zero

Floating-point divisor and dividend, there are three situations:

Positive divided by zero (0.0), the results for Infinity (is infinite)

Negative number divided by zero (0.0), the result was minus Infinity (minus Infinity)

(0.0) divided by the number 0 (0.0), the result is NaN (not a number)

Code:


Results:


Second, relations (compare) operator



Note: in Java==and equals () method is the difference between
==at the time of the basic data type is to compare values are the same, when a reference type is address equals to determine the value of a reference type

Three, logical operators


Four, the assignment operator


Five, the other operator
1, the ternary operator (? :)
The ternary operator is also known as the ternary operator, the operator has three operands, and need to judge the value of the Boolean expression, if the operator's main decide which value should be assigned to variables,
Format: variable x=(expression)? The value if true: the value if false
2, the instanceof operator
The operator is used for operation object instance, check whether the object is a particular type (type class or interface type),
Format: (Object reference variable) instanceof (class/interface type)

Six, operator (understand)



Seven, the Java language operator priority
Which is divided into 14 level, the highest level 1, level 14 minimum
  • Related