String (List<String> list) { // otherwise not null // if list is null // return null if (list == null) { return null; } else { for (String str : list) { if (str.contains("x")) { return str; } } return null; } }