Index

chapter1

chapter2page1

chapter2page2

chapter2page3

chapter2page4

chapter2page5

chapter2page6

chapter2page7

chapter2page8

chapter2page9

chapter2page10

chapter2page11

chapter2page12

chapter2page13

chapter2page14

chapter2page15

chapter2page16

chapter2page17

chapter2page18

chapter2page19

chapter2page20

chapter2page21

chapter2page22

chapter2page23

chapter2page25

chapter2page26

chapter2page27

chapter2page28

chapter2page29

chapter2page30

chapter2page31

chapter2page32

chapter2page33

chapter2page34

chapter3

link one

link one

link one

link one

link one

link one

2.6.8 - Equality Operators

There are two equality operators, == (equality operator) and != (nonequality operators). Equality operators are binary operators. Both of their operands may be

Equality operators have lower precedence order then the relational operators. The expression below,

m > n == t< s

The relational sub-expressions are first evaluated and their resulting values are compared for equality, This expression is better written for eliminating all misunderstandings by using parenthesis for explicitly explaining the order of evaluation as:

( m > n ) == ( t < s )

The returning type of the equaliy operators is always boolean.

2.6.8.1 - Boolean Equality Operators

In the boolean equality operator, when borh operands are true, the returning boolean value is true. Otherwise false will be returned. We can try with example shown below:

package preliminary;
public class BooleanEquality {
public static void main(String[] args){
boolean firstControl= true;
boolean secondControl= true;
boolean result = (firstControl == secondControl);
System.out.println(" Result = "  +  result);
 } // end main
} //end class BooleanEquality

The result of this program :

Result = true

The boolean inequality opeator != returns false only when both of the operands are false or true. It will return false in all other cases. An example is given below:

package preliminary;
public class BooleanInequality {
public static void main(String[] args){
boolean firstControl= true;
boolean secondControl= true;
boolean result = (firstControl != secondControl);
System.out.println(" Result = "  +  result);
 } // end main
} //end class BooleanInequality

The result of this program :

Result = false

<< Index

Polyglott HTML5(XHTML5 compliant HTML5 code)