2.6.3 - Bitwise Operators

There are four bitwise operators used for changing the bits of the integer data. These are bitwise AND (&), bitwise OR (|), bitwise exclusive OR (^) , bitwise complement (~)

Bitwise operators are intended to change the bits of the internally stored values of integer variables. A task not very compatible with the concept of Java, because Java is designed for saving the programmers from the need of bit hunting. We will not introduce these very unfrequently used operators. Anything they can do, may be done by more conventional ways in Java.

2.6.4 - Shift Operators

Shift operators are used for shifting the bits of the stored integer data. There are three shift operators. These are shift left(<<), shift right (>>), and shift right with zero filling (>>>) . We will not introduce these low- level shift operators.

2.6.5 - Logical Operators

Logical operators accept boolean operands and return boolean values. Returning boolean (logical) values may be stored in boolean variables. Logical operators are very important for any programming language including Java, because they provide true or false information. These logical data may be evaluated by the compiler and depending the results of the evaluation of logical (either true or false) values, the program may execute some statements instead of others. This is called branching. We will focus here to the obtention of boolean values relevant for program branching. Logical operators are here for that.

The result of any logical operator may be used for program branching as follows : If the result of the logical complement operator, is true let the program execute some statements, else execute other statements, otherwise continue to the program execution from the next step to the decision statement. By the way, there is no escape from implicit otherwise.

2.6.5.1 - Unary Logical Operator

The only unary logical operator is the logical complement operator! (NOT)

2.6.5.1.1 - Unary Logical Complement Operator !

Unary logical complement operator ! is simply a negation (NOT) operator. It returns the opposite of the boolean value of his operand. Example:

```package preliminary;
public class Negation {
public static void main(String[] args){
boolean control = false;
System.out.print(" Result = "  +  ! control);
} // end main
} //end class Negation
```

The result of this program :

```       Result = true

```

Looking to the program above, the priority of the logical complement operator is higher than the addition operator (Section 2.6, Tables 1 ,2 ,3). Therefore, the expression "Result = "+ !control evaluates first the complement of the variable control, then concatenation of the result by the string "Result =".