I have list List where Custom is like
List
Custom
class Custom{ public int id; public String name; }
How to
You could also sort the list before looping, then use divide-and-conquer to find matches, then count. It really depends on your needs, like how many elements? Are there a lot of insertions after a search? etc