Unary, Binary, and Ternary Operators

Quite simply, a unary operator is one that is used with one operand. For example, in the operator precedence table we see the second row contains the + and – unary operators, which may, for the unary minus operator, be used as follows:

int a = 10; int b = -a;

Hence, the minus sign preceding the variable a in the second line is a unary operator, used with one operator—the variable a.

Binary operators are used to perform an operation on two operands, such as the * operator for multiplying two numbers together.

There is only one ternary operator, which is the ?: conditional operator that uses three operands and is discussed a little later in this chapter.



Java 1.4 Game Programming
Java 1.4 Game Programming (Wordware Game and Graphics Library)
ISBN: 1556229631
EAN: 2147483647
Year: 2003
Pages: 237

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net