To retrieve a String consisting of all the ID’s separated by the delimiter "," you first have to map the Person ID’s into a new stream which you can then apply Collectors.joining on.
String result = personList.stream().map(Person::getId)
.collect(Collectors.joining(","));
if your ID field is not a String but rather an int or some other primitive numeric type then you should use the solution below:
String result = personList.stream().map(p -> String.valueOf(p.getId()))
.collect(Collectors.joining(","));