Question: ```
ArrayList searchList = new ArrayList();
ArrayList words=(ArrayList) request.getSession().getAttribute("words");
words.add("one");
words.add("twenty one");
words.add("thirty one");
words.add("two");
words.add("twenty two");
words.add("thirty two");
words.add("three");
words.add("twenty three");
words.add("thirty three");'

```

If I have this arraylist and I want to search all the strings containing one(i.e. one,twenty one and thirty one), what logic should I use? Means how should I do that?

Answer: 
```
for (String item : searchList) {
    if (item.contains("one") {
        // Do something. Like adding the result to a different list.
        // If you need the index from the original list, you a for instead of a for each
    }
 }

```
In general, when searching an item in a `List`, the best solution is to sort your `List` first using `Collections.sort()` method. Then using the `Collections.binarySearch()` method, find your element.
In this case your elements are `String` type that are `Comparable` and can be sorted alphabetically otherwise you needed to implement `Comparable` interface for your element class type.