Given a Collection of Strings, how would you join them in plain Java, without using an external Library?
Given these variables:
Collection
Your proposition is a possible solution, another common one is:
for (String item: data) { sb.append(item) sb.append(separator); } String joined = sb.substring(0, sb.length() - separator.length())