xxxxxxxxxx
// You can't just do String.join(", ", list) because
// the list has to be a String[]. This code works on
// everything.
list.stream().map(Object::toString).collect(Collectors.joining(", "));
xxxxxxxxxx
List<String> list = Arrays.asList("foo", "bar", "baz");
String joined = String.join(" and ", list); // "foo and bar and baz"
xxxxxxxxxx
List<String> list = Arrays.asList("a","b","c");
String result = String.join(",", list);
System.out.println(result); //prints a,b,c