Hi All,
I am getting out of memory exception at one point of time in the following code. Approximately when number of characters in the builder crosses 1 lakh.
public static String concatDelimiter(List<String> values, String delimiter) {
StringBuilder delimitedContent = new StringBuilder();
delimitedContent.append(" ");
if(values != null && values.size() > 0) {
int size = values.size();
for(int i = 0; i < size; i++) {
if(i < size - 1) {
delimitedContent.append(values.get(i) + delimitedContent);
} else {
delimitedContent.append(values.get(i));
}
}
}
return delimitedContent.toString();
}
Sample Input
*values =* PN, DP, ICT, EC, ECLM, PR, PRD, UCC, CO, IMG, DWC, MC, WEEK, PAN, DAB, IND, CK, DPR, TID, CL1
*delimiter =* ,
Why am I getting the exception? Does it has any size restrictions?
Note: Please dont ask what is the perpose of the method.