String string = list.stream().map(Object::toString).collect(Collectors.joining(""));
ArrayList<String> list = new ArrayList<String>();
list.add("one");
list.add("two");
list.add("three");
StringBuilder sb = new StringBuilder();
for (String s : list)
{
sb.append(s);
sb.append(" ");
}
System.out.println(sb.toString());
ArrayList<String> data = new ArrayList<String>();
data.add("First");
data.add("Second");
data.add("Third");
StringBuilder sb = new StringBuilder();
for (String item : data) {
sb.append(item).append("
");
}
sb.setLength(sb.length() - 1);
// generates output:
// First
// Second
// Third