這是從破解編碼採訪中得到的代碼。我不明白第4行和第5行。從我所看到的,它是數組列表的數組列表,但它對於它的定義有點困惑。請解釋一下這些行中實際發生的情況。數組列表?
1 public class CallHandler {
2 static final int LEVELS = 3; // we have 3 levels of employees
3 static final int NUM_FRESHERS = 5; // we have 5 freshers
4 ArrayList<Employee>[] employeeLevels = new ArrayList[LEVELS];
5 // queues for each call’s rank
6 Queue<Call>[] callQueues = new LinkedList[LEVELS];
7
8 public CallHandler() { ... }
9
10 Employee getCallHandler(Call call) {
11 for (int level = call.rank; level < LEVELS - 1; level++) {
12 ArrayList<Employee> employeeLevel = employeeLevels[level];
13 for (Employee emp : employeeLevel) {
14 if (emp.free) {
15 return emp;
16 }
17 }
18 }
19 return null;
20 }