package com.atguigu.project02;
public class CustomerList {
private Customer[] customers;
private int total = 0;//记录已保存客户对象的数量
/**
* 初始化customers数组
* @param totalCustomer:指定customers数组的最大空间
*/
public CustomerList(int totalCustomer){
customers = new Customer[totalCustomer];
//注意:此处new的customer数组是已经申明过的,所以前面不加Customer[]
}
}
初始化customers数组的时候,前面不能申明一次Customer[],否则就重新又建了一个数组,而不是之前那个customers了。