Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Search substring in arraylist

880368Oct 7 2011 — edited Oct 7 2011
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,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 4 2011
Added on Oct 7 2011
7 comments
1,804 views