如何使用ArrayList替换以下数组。
Employee[] companyTeam = {manager, engineer1, superviso1, accountant, intern };
答案 0 :(得分:3)
您可以执行类似
的操作List<Employee> companyTeam = Arrays.asList(manager, engineer1, superviso1, accountant, intern);
答案 1 :(得分:0)
Employee[] companyTeam = {manager, engineer1, superviso1, accountant, intern };
List<Employee> list=Arrays.asList(companyTeam);// array to List
您已有一个数组,因此您可以使用Arrays.asList(companyTeam)
将数组转换为List