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: 
```
//iterate through words
for(String str : list){
  //check if word contains the key
  if(str.contains(key)){ 
     //add its reference to another resultant list
     result.add(str);
  }
}

```
```
for (String word : words) {
   if (word.contains("one")) {
       //we have a match
   }
}

```