1. Computing & Technology

Discuss in my forum

Relational Operator

By , About.com Guide

Definition:

A relational operator compares two operands to determine whether one is greater than, greater than or equal to, less than, less than or equal to the other:

 >    greater than
 >=   greater than or equal to
 <    less than
 <=   less than or equal to
 

When used in an expression they all return a boolean value which states the result of the comparison (i.e., 4 > 3 can be read as is 4 greater than 3? Which returns true).

Examples:
 int three = 3;
 int four = 4;
 
 //is four greater than three?
 System.out.println(four > three); //true
 
 //is four greater than or equal to four?
 System.out.println(four >= four); //true
 
 //is four less than three?
 System.out.println(four < three); //false
 
 //is four less than or equal to three?
 System.out.println(four <= three); //false
 

Glossary:

# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

©2012 About.com. All rights reserved.

A part of The New York Times Company.