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

后端 未结 10 1264
你的背包
你的背包 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:11

    Anyone still stuck on this, try using a for-each loop.

    ArrayList list = new ArrayList<>(); // default size of 10
    
    /*add elements to 
    the ArrayList*/
    
    for(String element: list)
    System.out.println(element);
    

提交回复
热议问题