A quick and easy way to join array elements with a separator (the opposite of split) in Java

2024-09-23 | code | java, arrays, string

问题描述

See Related .NET question I'm looking for a quick and easy way to do exactly the opposite of split so that it will cause ["a","b","c"] to become "a,b,c"Iterating through an array requires either adding a condition (if this is not the last element, add the seperator) or using substring to remove the last separator.I'm sure there is a certified, efficient way to do it (Apache Commons?)How do you prefer doing it in your projects?

提示词

None
Loading...