Java Reference
In-Depth Information
Chapter 7
Java Operators
The Action Element
An
expression
in a programming language consists of operators and
operands.
Operators
arespecialsymbolsthatindicatespecificprocessing
action.Forexample,toaddtwovaluesinanexpression,weusethefamiliar
+ sign, which is the addition operator in Java. Other operators are not as
commonasthe+and-symbols.Suchisthecasewiththe&&symbolwhich
isoneofthelanguage'slogicaloperators.Inthischapterwestartlookingat
the Java operators.
Operators
Operators are the symbols and special characters used in a programming
language to change the value of one or more program elements. The pro-
gramelementsthatarechangedbyanoperatorarecalledthe
operand
.We
usethe+symboltoperformthesumoftwooperands,asinthefollowingex-
ample:
int val1 = 7;
int val2 = 3;
int val3 = val1 + val2;
Programmers note:
The+symbolisalsousedinappendingstrings.Whenusedinthisman-
ner it is called the
concatenation operator
. String concatenation is
discussed later in this chapter.