I want to join a String[]
with a glue string. Is there a function for this?
Java function for arrays like PHP’s join()
arraysjavajoin;
Related Topic
- Java – How to read / convert an InputStream into a String in Java
- Javascript – How to insert an item into an array at a specific index (JavaScript)
- Java – How to determine whether an array contains a particular value in Java
- Javascript – How to empty an array in JavaScript
- Javascript – How to check if an object is an array?
- Java – How to convert a String to an int in Java
- Javascript – How to remove a specific item from an array
- Java – Why is processing a sorted array faster than processing an unsorted array
Best Answer
Starting from Java8 it is possible to use
String.join()
.Generates:
Otherwise, Apache Commons Lang has a
StringUtils
class which has ajoin
function which will join arrays together to make aString
.For example:
Generates the following
String
: