0
I have the following condition IF
:
(ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString()))
How can I verify if the variables are different, ie deny this condition in the same IF
0
I have the following condition IF
:
(ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString()))
How can I verify if the variables are different, ie deny this condition in the same IF
6
If the goal is to reverse the condition, just 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 the equality of true or false objects), it is never too much to remember that you should use if...else
, avoiding chains of ifs with inverse conditions among themselves:
if(ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString())) {
//faça algo caso sejam iguais
} else {
//faça algo se forem diferentes
}
Perfect, was exactly deny my condition I needed, so release I already mark as accept the question
Browser other questions tagged java if
You are not signed in. Login or sign up in order to post.
You want to reverse the equals condition, that’s it?
– user28595
Do you know the logical negation operator? The operator
!
– Jefferson Quesado