如何用arraylist替换数组?

时间:2014-01-23 14:39:48

标签: java

如何使用ArrayList替换以下数组。

Employee[] companyTeam = {manager, engineer1, superviso1, accountant, intern };

2 个答案:

答案 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