Answer:
public static List<String> listSearch(String searchFor, List<String> list){
List<String> foundList = new ArrayList<String>();
for(String s:list){
if(s.contains(searchFor)){
foundList.add(s);
}
}
return foundList;
}
Step-by-step explanation:
Create a method named listSearch that takes two parameters, a String named searchFor and a String list named list
Inside the method, initialize a new String list named foundList, this will be used to hold the strings that contains the target string. Create a for loop that iterates through the list. Check if a string in the list contains the searchFor using the contains method. If it does, add the string to the foundList. When the loop is done, return the foundList.