1

I have list with some values: List<String> list = Arrays.asList("1","2","3");

I want convert it to String "1; 2; 3"

I have only idea with loop. It works but it doesn't looks elegant. Maybe somebody can advice more easy way to do it?

  • With Streams: `list.stream().collect(Collectors.joining("; "))`. But `String::join` is probably more elegant. – MC Emperor Dec 07 '22 at 11:39

1 Answers1

1

Try to use String.join("; ", list) It should work