Concatenating elements in an array to a string

前端 未结 19 2274
慢半拍i
慢半拍i 2020-12-08 02:43

I\'m confused a bit. I couldn\'t find the answer anywhere ;(

I\'ve got an String array:

String[] arr = [\"1\", \"2\", \"3\"];

then

19条回答
  •  -上瘾入骨i
    2020-12-08 03:10

    For Spring based projects:

    org.springframework.util.StringUtils.arrayToDelimitedString(Object[] arr, String delim)

    For Apache Commons users, set of nice join methods:

    org.apache.commons.lang.StringUtils.join(Object[] array, char separator)

提交回复
热议问题