Comparison operators determine if one operand is greater than, less than, Equal to, or not equal to another operand.

 Operator Description Example == Equal to a==b Returns True if a is equal to b, else false /= Not equal to a/=b returns true if a is not equal to b, else false. > Greater than a>b returns true, if a is > b, else false >= Greater than or equal to a>=b returns true, if a is >= b, else false. < Less than a

`*Main> let a = 10*Main> let b = 12*Main> *Main> a == bFalse*Main> a /= bTrue*Main> a > bFalse*Main> a < bTrue*Main> a >= bFalse*Main> a <= bTrue`

Operators are implemented as functions internally.

10 == 12 is represented as '(==) 10 12', note that the function name must be enclosed in parenthesis.
`*Main> (==) 10 12False*Main> (/=) 10 12True*Main> (>) 10 12False*Main> (<) 10 12True*Main> (>=) 10 12False*Main> (<=) 10 12True`

Previous                                                 Next                                                 Home

This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here