Implode an Array in Java

Its quite simple to implement the function, you may know from

php, which concats all elements from an array as string and puts a seperator between those.

The following code snippet, takes all elements from inputArray (e.g. 1 2 and 3) and concat them to "1,2,3" and saves this into AsImplodedString.

String AsImplodedString;
if (inputArray.length==0) {
    AsImplodedString = "";
} else {
    StringBuffer sb = new StringBuffer();
    for (int i=1;i<inputArray.length;i++) {
    AsImplodedString = sb.toString();

This implementation uses a StringBuffer to be faster with big arrays.

In java, open source by
@ 11 Apr 2008, Comments at Reddit & Hackernews