The 30 second answer
I filter employees whose name is non-null and starts with the prefix, then collect to a list. I ask about case sensitivity and null names up front so we do not argue about edge cases after coding.
List<Employee> r = emps.stream()
.filter(e -> e.name() != null && e.name().startsWith(prefix))
.toList();Ask about case sensitivity (regionMatches(true, 0, prefix, 0, prefix.length())) and null names before coding.
Sources:
Sources (0)
See inline citations in the answer above.