public List<Person> selectAllPeople() {
return List.of(new Person(UUID.randomUUID(), "From Postgres DB"));
}
What other alternative I can use other than List.of
to generate same output?
public List<Person> selectAllPeople() {
return List.of(new Person(UUID.randomUUID(), "From Postgres DB"));
}
What other alternative I can use other than List.of
to generate same output?
You can use Collections.singletonList
.
Returns an immutable list containing only the specified object. The returned list is serializable.
return Collections.singletonList(new Person(UUID.randomUUID(), "From Postgres DB"));