How to write the elements of the ArrayList?

Hi all. I'm starting to learn Java and have run into a problem. I have an ArrayList, how can I write elements with him, that they were discharged in square brackets as Arrays.toString(x)?
Right now I have issued this:
8ca55e3a7322477e9c7a9525f149b62d.png
It should be:
478533cc72bc416597be89ba37d22fa2.png

And yet, I have on the 1st picture at the end of the last element with a comma. How to make so that it are not displayed??
Or just standing as it is to translate this ArrayList to a regular array? But how?
Thank you
July 2nd 19 at 13:54
2 answers
July 2nd 19 at 13:56
Solution
List List = new ArrayList();

 for(int i=0; i < 20; i++)
list.add(System.nanoTime());

 //ArrayList to Array;
 Long[] mArray = new Long[list.size()];

 for(int i=0; i< mArray.length; i++)
 mArray[i] = (Long) list.get(i) ;

 System.out.println(list.size()+ "" + list.toString());
 System.out.println(Arrays.toString(mArray));
July 2nd 19 at 13:58
The best minds in the Java community over the years have struggled with this problem and if you do a little googling to find out what they came up with.

Find more questions by tags Java