Not equal to operator
From Coderwiki
More actions
One common comparison operator is the not equal to operator.
This operator will return true if the value on the left is different to the value on the right of the operator.
Syntax
edit edit sourceIn most languages, the not equal to operator is represented by a != symbol.
Equivalence to inverting the result of an equal to operator comparison
edit edit sourceThese two code snippets generally return exactly the same result:
boolean a = 5 != 3; // true
boolean b = !(5 == 3); // also true
boolean c = a == b; // true
Comparison of different types
edit edit sourceMost programming languages (with the notable exception of JavaScript) will return false if the two values being compared are of a different type.
For example, if we compare the number 5 with the string "5", the result will be false because the values were of different types.
See JavaScript equal to operator for info on how JavaScript handles the equal to operator(s).
Example
edit edit sourceboolean a = 7 == 7; // true
boolean b = 6 == 7; // false
boolean c = 5 == "5"; // false... unless you're using JavaScript!