In Java 8 or later:
String listString = String.join(", ", list);
In case the list
is not of type String, a joining collector can be used:
String listString = list.stream().map(Object::toString)
.collect(Collectors.joining(", "));
More Related Contents:
- Check to see if two arraylists contain a similar component [duplicate]
- Android String that change every day
- Converting ‘ArrayList to ‘String[]’ in Java
- ArrayList initial capacity and IndexOutOfBoundsException [duplicate]
- How to convert a String into an ArrayList?
- Sorting ArrayList of Objects by Object attribute
- incompatible types required char found java.lang.string
- String, StringBuffer, and StringBuilder
- String concatenation: concat() vs “+” operator
- How do I make my ArrayList Thread-Safe? Another approach to problem in Java?
- How can I use “.” as the delimiter with String.split() in java [duplicate]
- Java: how can I split an ArrayList in multiple small ArrayLists?
- How to sort an ArrayList using multiple sorting criteria?
- How to convert current date into string in java?
- Reverse a given sentence in Java
- Remove end of line characters from Java string
- String Deduplication feature of Java 8
- Convert String to Uri
- Searching in a ArrayList with custom objects for certain strings
- java.util.Vector – alternatives
- ArrayList or List declaration in Java
- Arrays.asList() of an array
- Remove all non-“word characters” from a String in Java, leaving accented characters?
- Simple way to sort strings in the (case sensitive) alphabetical order
- Vector vs Collections.synchronizedList(ArrayList)
- What’s the best way to check if a String contains a URL in Java/Android?
- What’s the quickest way to compare strings in Java?
- Random element from string array [closed]
- Hints for java.lang.String.replace problem? [duplicate]
- What is difference between mutable and immutable String in java