Created
May 31, 2020 13:49
-
-
Save swapnilshrikhande/1071aad7c6e9c0eeafa4c937b26795aa to your computer and use it in GitHub Desktop.
Apex Join
This file contains hidden or 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
String join(List<String> values) { | |
List<String> valueCopy = new List<String>(values); | |
if(valueCopy.isEmpty()) | |
return null; | |
String result = valueCopy[0]; | |
valueCopy.remove(0); | |
while(!valueCopy.isEmpty()) { | |
result += ',' + valueCopy[0]; | |
valueCopy.remove(0); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment