【发布时间】:2019-04-30 04:01:46
【问题描述】:
我和我的朋友正在为我们的编程考试学习示例编程考试,并且在使用数组列表作为参数从同一类中的数组列表中删除多个项目的方法中遇到问题。
我们已经尝试搜索网络并使用我们的 BlueJ 教科书来寻找解决方案。
我们的作业表上的说明是:“编写一个带有字符串数组 itemArray 参数的方法 removeItemFromOrder 以从订单中删除多个食品。”
import java.util.ArrayList;
/**
* Write a description of class Order here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Order
{
// instance variables - replace the example below with your own
private ArrayList<OrderedItem> order;
/**
* Constructor for objects of class Order
*/
public Order()
{
order = new ArrayList<>();
}
/**
* Returns the order collection to the user.
* @return the order collection.
*/
public ArrayList getOrder()
{
return order;
}
/**
* Add an item to the order.
* @param OrderedItem the item to be added
*/
public void addOrderItem(OrderedItem foodItem)
{
order.add(foodItem);
}
public void removeOrderItem(ArrayList<String> itemArray)
{
//**We don't know what to put here!**
}
}
【问题讨论】:
-
添加数组列表作为参数stackoverflow.com/q/17125270/8631622从数组列表中删除多个项目stackoverflow.com/q/203984/8631622
标签: java arrays arraylist collections