String (List<String> list) { Optional<String> found = Optional.empty(); for (String s : li<caret>st) { if (Objects.nonNull(s)) { found = Optional.of(s); // optional! break; } } return found.orElse(null); }