Concatenating elements in an array to a string

前端 未结 19 2267
慢半拍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条回答
  • 2020-12-08 03:17

    This is a little code of convert string array to string without [ or ] or ,

    String[] strArray = new String[]{"Java", "String", "Array", "To", "String", "Example"};
    
    String str = Arrays.toString(strArray);
                str = str.substring(1, str.length()-1).replaceAll(",", "");
    
    • First convert array to string.
    • Second get text from x to y position.
    • third replace all ',' with ""
    0 讨论(0)
提交回复
热议问题