|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
The following table lists the operators supported by the Java programming language.
All Operators Operator Use Description ++opPromotes optointif it's abyte,short, orchar--opArithmetically negates op+op1 + op2Adds op1andop2; also used to concatenate strings-op1 - op2Subtracts op2fromop1*op1 * op2Multiplies op1byop2/op1 / op2Divides op1byop2%op1 % op2Computes the remainder of dividing op1byop2++op++Increments opby 1; evaluates to the value ofopbefore it was incremented++++opIncrements opby 1; evaluates to the value ofopafter it was incremented--op--Decrements opby 1; evaluates to the value ofopbefore it was decremented----opDecrements opby 1; evaluates to the value ofopafter it was decremented>op1 > op2Returns trueifop1is greater thanop2>=op1 >= op2Returns trueifop1is greater than or equal toop2<op1 < op2Returns trueifop1is less thanop2<=op1 <= op2Returns trueifop1is less than or equal toop2==op1 == op2Returns trueifop1andop2are equal!=op1 != op2Returns trueifop1andop2are not equal&&op1 && op2Returns trueifop1andop2are bothtrue; conditionally evaluatesop2||op1 || op2Returns trueif eitherop1orop2istrue; conditionally evaluatesop2!!opReturns trueifopisfalse&op1 & op2Returns trueifop1andop2are both boolean and bothtrue; always evaluatesop1andop2; if both operands are numbers, performs bitwiseANDoperation|op1 | op2Returns trueif bothop1andop2are boolean and eitherop1orop2istrue; always evaluatesop1andop2; if both operands are numbers, performs bitwise inclusiveORoperation^op1 ^ op2Returns trueifop1andop2are different that is, if one or the other of the operands, but not both, istrue<<op1 << op2Shifts bits of op1left by distanceop2; fills with0bits on the right side>>op1 >> op2Shifts bits of op1right by distanceop2; fills with highest (sign) bit on the left side>>>op1 >>> op2Shifts bits of op1right by distanceop2; fills with0bits on the left side&op1 & op2Bitwise ANDif both operands are numbers;
conditionalANDif both operands are boolean|op1 | op2Bitwise ORif both operands are numbers;
conditionalORif both operands are boolean^op1 ^ op2Bitwise exclusive OR(XOR)~~opBitwise complement =op1 = op2Assigns the value of op2toop1+=op1 += op2Equivalent to op1 = op1 + op2-=op1 -= op2Equivalent to op1 = op1 - op2*=op1 *= op2Equivalent to op1 = op1 * op2/=op1 /= op2Equivalent to op1 = op1 / op2%=op1 %= op2Equivalent to op1 = op1 % op2&=op1 &= op2Equivalent to op1 = op1 & op2|=op1 |= op2Equivalent to op1 = op1 | op2^=op1 ^= op2Equivalent to op1 = op1 ^ op2<<=op1 <<= op2Equivalent to op1 = op1 << op2>>=op1 >>= op2Equivalent to op1 = op1 >> op2>>>=op1 >>>= op2Equivalent to op1 = op1 >>> op2?:op1 ? op2 : op3If op1istrue, returnsop2; otherwise, returnsop3[]See Creating and Using Arrays ![]()
Used to declare arrays, to create arrays, and to access array elements .See Using Objects Used to form long names (params)See Defining Methods Delimits a comma-separated list of parameters (type)(type) opCasts (converts) opto the specified type; an exception is thrown if the type ofopis incompatible with typenewSee Using Objects and Creating and Using Arrays
Creates a new object or array instanceofop1 instanceof op2Returns trueifop1is an instance ofop2
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.