How can i reduce or collect a list of string delimitted by comma and prefixed "and" only to the last element using Java 8 Streams?
eg.
List<String> ls = Arrays.asList("tom","terry","john","kevin","steve");
String result = ls.stream().map(String::toString)
.collect(Collectors.joining(", "));
System.out.println(result);
This statement prints => tom, terry, john, kevin, steve. But i wanted to print the list as tom, terry, john, kevin and steve.