Output ArrayList to String without [,] (brackets) appearing

后端 未结 10 1248
你的背包
你的背包 2020-12-17 10:30

OK, so I have an ArrayList that I need to return as a String. Right now I am using this approach:

List customers = new ArrayList<>();
L         


        
10条回答
  •  抹茶落季
    2020-12-17 11:18

    You can try this.

    String listAsStr = myList.toString(); // get list as string
    listAsStr = listAsStr.substring(1,listAsStr.length()-1); // removing first and last bracket
    

    This will return the string without first and last brackets.

提交回复
热议问题