How to remove the brackets [ ] from ArrayList#toString()?

后端 未结 11 2361
攒了一身酷
攒了一身酷 2021-01-03 14:09

I have created an Array List in Java that looks something like this:

 public static ArrayList error = new ArrayList<>();

for (int x= 1         


        
11条回答
  •  离开以前
    2021-01-03 14:41

    You can write like this.

    String output = errors.toString().replaceAll("(^\\[|\\]$)", "");

提交回复
热议问题