Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I express that two values are not equal to eachother?

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).

like image 939
cdo Avatar asked Dec 03 '11 04:12

cdo


People also ask

How do you express does not equal?

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 "≠ ".

What is it called when two values are not equal?

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.

How do you say not equal to in Java?

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.

How do you write greater than or equal to?

The symbol ≥ means greater than or equal to.


1 Answers

"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
like image 128
Anthony Pegram Avatar answered Oct 13 '22 16:10

Anthony Pegram