0
Usually to perform a conditional using an array or a list and need to perform a for and perform the if line by line in this way.
//sendo item uma string e listaItens um List<String>
for(String lista: listaItens){
if(item.equal(lista){
return true;
}
}
I would like to know if there is a more effective way to carry out this operation where the property if already makes the comparison with the entire list without the need for the for example if(variavel.equal(lista.asItem)
or something like that.
What do you want with this code? Find only an equal value or all that are equal?
– user28595
only find an equal, need to know if the variable has the value equal to one of the elements of the list, if yes I am obliged to use this value, if not I have to ignore the value contained in the variable.
– Juliano Silveira