no title...

Page 62

What is the postfix increment value of 10? 11 What is the prefix decrement value of 3? 2 What is the postfix decrement value of 3? 2

In this example, line five declares and initializes the variables. Variable “x” is assigned 10 while “y” is assigned three. An + (Addition) operator adds both variables in line seven. Variable “result” is assigned the sum of variables “x” and “y” which results in 13. A similar process is performed for all examples in Figure 3.3 using a different Arithmetic Operator according to Figure 3.2.

Bitwise Operators The Bitwise Operator work on operands utilizing bits. Therefore this operator have a foundation that functions on a bit-by-bit basis. Values are made available after the bits are set, shifted, and tested. Primarily, the Bitwise Operators are used on data types byte, char, int, long, and short. The following is a list of bitwise operators and examples:

& (Bitwise AND) operator | (Bitwise OR) operator ^ (Bitwise exclusive OR (XOR)) operator >> (Signed shift right) operator >>> (Unsigned shift right) operator << (Signed shift left) operator ~ (One’s Compliment) operator

Operator &

Description Places 1 bit in the result if a bit exists in both operands. Can be used on a boolean data type

Example x & y;


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.