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

后端 未结 11 2432
攒了一身酷
攒了一身酷 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:40

    There are not brackets inside your list. This is just the way Java prints a list by default.

    If you want to print the content of your list, you can something like this

    for (Integer error : errors) {
        System.out.format("%d ", error);
    }
    

提交回复
热议问题