If I have an arraylist as below
ArrayList arrayList = new ArrayList();
arrayList.add("cat");
arrayList.add("shift");
arrayList.add("rat");
arrayList.add("whatever");
I would like to get all the elements from this list that match pattern, for example "at". I would like the output to give me "cat" and "rat", may be in a collection. I have to search various other patterns against this arraylist. Is there a generic method provided in java instead of iterating and then checking every element if it contains the pattern.
Appreciate your help. Thanks,