How to create a comma separated string using StringJoiner in Java

This small example shows how to create a comma separated value using the StringJoiner class. The StringJoiner class takes a delimiter as parameter to its constructor which is appended after each value that is added (except for the last one). Finally we use the toString method to print out the value, like this:

The output from the above will look like this:

Search for more Java info on this site here:
Custom Search

Please type any questions here.