如何用ArrayList替换数组?

这个问题在这里已经有了答案:

  • 从数组32中创建ArrayList答案

  • 你可以做类似的事情

    List<Employee> companyTeam = Arrays.asList(manager, engineer1, superviso1, accountant, intern);
    

     Employee[] companyTeam = {manager, engineer1, superviso1, accountant, intern };
     List<Employee>  list=Arrays.asList(companyTeam);// array to List
    

    你已经有了一个数组,所以你可以使用Arrays.asList(companyTeam)将数组转换为List

    链接地址: http://www.djcxy.com/p/17635.html

    上一篇: How do i replace an array with an arraylist?

    下一篇: The best way to transform int[] to List<Integer> in Java?