我有一个任务要求我制作有序的字符串列表对象。我目前有 2 个有序字符串列表,每个列表中有 7 个字符串值。我试图创建一种方法,将列表 myList 和 yourList 合并为组合列表 combineList。
这是我到目前为止所拥有的。
public boolean merge(OrderedStringList myList, OrderedStringList yourList){
int index;
String value;
for (index = 0;index < numUsed; index++){
value = myList.storage[index];
combinedList.insert(value);
}
for (index = 0;index < numUsed; index++){
value = yourList.storage[index];
combinedList.insert(value);
}
}
我在我的 main 中声明了对象 combineList,但它在我的 orderedStringList.class 中无法识别它
insert 函数将按字母顺序插入字符串。