java obtain list string from list object

Java
List<String> ids = 
  foos.stream().map(foo -> foo.getId()).collect(Collectors.toList());
Source

Also in Java: