I have the following condition IF
:
(ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString()))
How can I check if the variables are different, ie deny this condition in the same IF
I have the following condition IF
:
(ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString()))
How can I check if the variables are different, ie deny this condition in the same IF
If the purpose is to reverse the condition, simply use the negation operator at the beginning:
if(!ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString())) {
//faça algo caso sejam diferentes
}
However, if you need to do some action in both situations (be it true or false object equality), it is never too much to remember that you should use if...else
, avoiding ifs strings with inverse conditions between each other: p>
if(ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString())) {
//faça algo caso sejam iguais
} else {
//faça algo se forem diferentes
}