I have a code where I need to check if two entries are true.
I'm doing this:
if (!estudante.getOutTotal.equals("0") && !estudante.getOutEmAtendimento.equals.("0")) {
// Faz algo...
itens.add(estudante);
}
If the totals of Outbound and Outbound are values "0" I do not want to add to my list now in this situation it could happen that OutOfAssembly is "0" but outTotal is "50" ... in this case it would be necessary to add in the list but this logic does not do this.
I did this:
if (!estudante.getOutTotal.equals("0") && !estudante.getOutEmAtendimento.equals.("0")) {
// Faz algo...
itens.add(estudante);
} else if (!estudante.getOutTotal.equals("0") || !estudante.getOutEmAtendimento.equals.("0")) {
// Faz algo...
itens.add(estudante);
}
So not to delete all of them I check whether or one or the other is not zero if I do not add to the list.
Is that right? Is there any better way to do it?
At first I made a basic improvement and it worked as I expected.
Follows:
if (!estudante1.equals("0") && !estudante2.equals("0")) {
itens.add(estudante1);
itens.add(estudante2);
System.out.println("1 if");
} else if (!estudante1.equals("0") || !estudante2.equals("0")) {
itens.add(estudante1);
System.out.println("2 if");
itens.add(estudante2);
}