The relational operators determine the relationship between two operands. The relational operators are:
Relational Operators
| Operator | Result |
|---|---|
| == | Equal to |
| != | Not equal to |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal to |
| <= | Less than or equal to |
The outcome of relational operators is a boolean value. For example, the following code fragment is perfectly valid:
public class Main {
public static void main(String[] argv) {
int a = 4;
int b = 1;
boolean c = a < b;
System.out.println("c is " + c);
}
}
The result of a < b (which is false) is stored in c.
c is false
java2s.com | | Contact Us | Privacy Policy |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |