How do i replace an array with an arraylist?

This question already has an answer here:

  • Create ArrayList from array 32 answers

  • 你可以做类似的事情

    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/17636.html

    上一篇: 如何将类数据从数组传递到ArrayList

    下一篇: 如何用ArrayList替换数组?