Created
June 10, 2015 08:21
-
-
Save herusdianto/2e70fb647c0b3884dc7f to your computer and use it in GitHub Desktop.
Groovy Implode Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def implode(ArrayList inputArray, String glueString) | |
{ | |
/** Output variable */ | |
String output = ""; | |
if (inputArray.size() > 0) | |
{ | |
StringBuilder sb = new StringBuilder(); | |
sb.append(inputArray[0]); | |
for (int i = 1; i < inputArray.size(); i++) | |
{ | |
sb.append(glueString); | |
sb.append(inputArray[i]); | |
} | |
output = sb.toString(); | |
} | |
return output; | |
} | |
// reference: https://imwill.com/implode-string-array-java/#.VXfzZ62lyko |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment