The Basics : Relational Operators used in coding
Both in Java and .NET (especially in terms of C#), the same relational operators and syntax are used in conditions. Below find them listed together with a definition and an example of each:
Operator:
|
Definition
|
Example:
|
Meaning:
|
<
|
less than
|
If (x < y) {
}
|
If x is less than y… do something
|
>
|
greater than
|
If (x > y) {
}
|
If x is greater than y… do something
|
<=
|
less or equal to
|
If (x <= y) {
.=
}
|
If x is less or equal to y… do something
|
>=
|
greater or equal to
|
If (x >= y) {
}
|
If x is greater or equal to y… do something
|
==
|
equal to
|
If (x == y) {
}
|
If x is equal to y… do something
|
!=
|
not equal to
|
If (x !=y) {
}
|
If x is not equal to y… do something
|