is there any way to check if a collection contain a value or more with better performance than looping twice with contains?
in other meaning something that would loo
contains takes only one param
if(person.contains("Joe") || person.contains("Jasha")){
// do something
}
If you are worrying about N number of elements
String[] items ={"Joe","jon","And So On".....};
for (String item : items ) {
if (person.contains(item)) {
//found
break;
}
}
Edit:
That || is most helpful in your case, since you have the benefit of Short-circuit_evaluation
The second argument is only executed or evaluated if the first argument does not suffice to determine the value of the expression: