/**
* Creates and returns an array of media items that match the call number.
* The length of the returned array is equal to the number of media items
* that match the call number, and each element in the array is one of the
* matching media items.
*
* @param callNumber the call number of the media items
* @return an array of matching media items.
*/
public MediaItem [] findItems(String callNumber)
{
MediaItem[] tmp = new MediaItem[MAX_ITEMS];
for (int i = 0; i <= inventory.size(); i++)
{
int j = inventory.indexOf(callNumber);
tmp.add(inventory.get(j));
return tmp;
}
}
包括该方法的描述,我正在尝试添加到创建的 tmp 数组中,但是使用 .add() 不起作用,因为对于这个项目,添加的对象是 MediaItem,而不是 int 或 String,所以我不不知道该怎么办。