Doubt regarding output format

How do I output in the given format?
in arraylist
if i were to transverse through array, I’ll be able to print elements only.

@Nupur1331
hello nupur,
No need to return any arrylist,
just print in the required output format
image

i.e first print [
then comman separated array elements
and then ]