Converting ArrayList of Characters to a String?

前端 未结 11 2153
清歌不尽
清歌不尽 2020-12-05 13:39

How to convert an ArrayList to a String in Java? The toString method returns it as [a,b,c] string - I wa

11条回答
  •  臣服心动
    2020-12-05 13:51

    You can do it using toString() and RegExp without any loops and streams:

    List list = Arrays.asList('a', 'b', 'c'); String s = list.toString().replaceAll("[,\\s\\[\\]]", "");

提交回复
热议问题