print arraylist element?

前端 未结 7 393
日久生厌
日久生厌 2021-01-11 13:59

how do i print the element \"e\" in arraylist \"list\" out?

 ArrayList list = new ArrayList();
 Dog e = new Dog();
 list.add(e);
 Syste         


        
相关标签:
7条回答
  • 2021-01-11 14:38

    Printing a specific element is

    list.get(INDEX)
    

    I think the best way to print the whole list in one go and this will also avoid putting a loop

    Arrays.toString(list.toArray())

    0 讨论(0)
提交回复
热议问题