Java Reference
In-Depth Information
In this case, the value of integer variable val3 (10) is found by adding
the values of variables val1 and val2. The fundamental Java operators
can be functionally classified as follows:
simple assignment
arithmetic
concatenation
increment and decrement
logical
bitwise
compound assignment
In this chapter we discuss the assignment, arithmetic, concatenation,
increment and decrement operators. The logical and bitwise operators
are the topic of Chapter 8.
Java operators are classified according to the number of operands as
follows:
unary
binary
ternary
TheoneJavaternaryoperator(?:)isdiscussedinChapter9,inthecon-
text of decision constructs.
Operator action
Javaoperatorsareusedinexpressionsthatproduceprogramactions.For
example, if a , b , and c are variables, the expression
c=a+b;
usesthe=andthe+operatorstoassigntothevariablecthevaluethatre-
sultsfromaddingthevariables a and b .Theoperatorsinthisexpressionare
the = (assignment) and + (addition) symbols.
Java operators must be used as elements of expressions; they are
meaningless when used by themselves. In this sense the term
-a;
isatrivialexpressionthatdoesnotchangethevalueofthevariable.Onthe
other hand, the expression
Search WWH ::




Custom Search