Is there a method similar to equals()
that expresses "not equal to"?
An example of what I am trying to accomplish is below:
if (secondaryPassword.equals(initialPassword))
{
JOptionPane.showMessageDialog(null, "You've successfully completed the program.");
} else {
secondaryPassword = JOptionPane.showInputDialog(null, "Your passwords do not match. Please enter you password again.");
}
I am trying to find something that will not require me to use if ( a != c)
.
The not equal symbol is a sign of "inequality". It is meant to show a comparison between the two quantities which are unequal hence, representing inequality among them. It is represented by two parallel horizontal lines cut by an inclined vertical line as (≠ ). The symbol used to show the not equal to sign is "≠ ".
In mathematics, an inequality is a relation which makes a non-equal comparison between two numbers or other mathematical expressions. It is used most often to compare two numbers on the number line by their size.
It is symbolized "!= " or "(!a. equals(b))" and checks if the values of two operands are equal or not, in case that values are not equal then condition becomes true.
The symbol ≥ means greater than or equal to.
"Not equals" can be expressed with the "not" operator !
and the standard .equals
.
if (a.equals(b)) // a equals b
if (!a.equals(b)) // a not equal to b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With