I have a few Set
s and want to transform each of these into a single String
where each element of the original Set
is sep
Maybe a shorter solution:
public String test78 (Set set) {
return set
.stream()
.collect(Collectors.joining(" "));
}
or
public String test77 (Set set) {
return set
.stream()
.reduce("", (a,b)->(a + " " + b));
}
but native, definitely faster
public String test76 (Set set) {
return String.join(" ", set);
}