I have this part of code:
if (CollectionUtils.isNotEmpty(itemAttValues)) { return String.join(";", itemAttValues); }
and i get this : 9000;9001
but what i want is 9000;9001;
so on last string to add ;
also.
Any suggestion?
Advertisement
Answer
I don’t know if you are working with an array or a ArrayList/List.
For an array:
if (CollectionUtils.isNotEmpty(itemAttValues)) { if (intemAttVallues.legnth != 1) { return String.join(";", itemAttValues) + ";"; } return itemAttValues[0] + ";"; }
For a ArrayList/List:
if (CollectionUtils.isNotEmpty(itemAttValues)) { if (intemAttVallues.size() != 1) { return = String.join(";", itemAttValues) + ";"; } return itemAttValues.get(0) + ";"; }