Page 340 - Computer_Science_F5
P. 340
Table 5.8: Relational operators
Operator type Symbol Description Syntax example
Less than or <= Evaluates if the left A <= B
equal to operand is less than or Chapter Five: Object oriented programming with Java
FOR ONLINE READING ONLY
equal to the right operand
Greater than or >= Evaluates if the left A >= B
equal to operand is greater than or
equal to the right operand
Instance of operator This verifies if the object boolean result = name
belongs to a specific type instanceof
(class or interface) by String;
using the syntax: (Object
reference variable)
instanceof (class/interface
type).
Equal to == Evaluates if the values of A == B
two operands are equal
Not equal to != Evaluates if the values A != B
of two operands are not
equal
Greater than > Evaluates if the value of A > B
left operand is greater than
the value of right operand
Less than < Evaluates if the value of A < B
left operand is less than
the value of right operand
Practice how the program works, just write the Program Example 5.7 in any editor
then compile and run the program in JDK using cmd.exe:
331
Student’s Book Form Five
Computer Science Form 5.indd 331 23/07/2024 12:34

