SCJP Study Guide:
Fundamentals


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend


Previous Next vertical dots separating previous/next from contents/index/pdf Contents
XyzWs SCJP Study Guide: Operators

Operators In Java

An operator is a symbol that operates on one or more arguments to produce a result. Java provides a rich set of operators for manipulating program data.

Operators work in conjunction with operands, or the literal values or variables involved in the operation. There are unary operators, which are operators that operate on a single operand, as well as operators that operate on two or more variables.

In Java, the order of evaluation of operands in an expression is fixed. All operands are evaluated from left to right. The order of execution of the operations may be completely different. The following table lists the most commonly used operators:

Operator Purpose
+ addition of numbers, concatenation of Strings
+= add and assign numbers, concatenate and assign Strings
- subtraction
-= subtract and assign
* multiplication
*= multiply and assign
/ division
/= divide and assign
% take remainder
%= take remainder and assign
++ increment by one
-- decrement by one
> greater than
>= greater than or equal to
< less than
<= less than or equal to
! boolean NOT
!= not equal to
&& boolean AND
|| boolean OR
== boolean equals
= assignment
~ bitwise NOT
?: conditional
instanceof type checking
| bitwise OR
|= bitwise OR and assign
^ bitwise XOR
^= bitwise XOR and assign
& bitwise AND
&= bitwise AND and assign
>> shift bits right with sign extension
>>= shift bits right with sign extension and assign
<< shift bits left
<<= shift bits left and assign
>>> unsigned bit shift right
>>>= unsigned bit shift right and assign

 


Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |