In the program I'm writing on, I'll have to check if a List (actually I can replace the type of Collection if necessary) contains a specific String.
Is this the fastest way to do it?
private boolean containsItem(List<String> list, String path) {
for (String s : list) {
if (s.equals(path)) {
return true;
}
}
return false;
}
I'm asking for performance only, as this operation may happen a couple of thousand times in a row.