我有一个任务,需要我做有序的字符串列表对象。 我目前有2个有序的字符串列表,每个字符串中有7个字符串值。 即时通讯尝试创建一个方法,将list myList和yourList合并成组合列表combinedList。合并字符串的两个对象。 java
这是我到目前为止。
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);
}
}
我声明对象combinedList在我的主,和它不承认它在我的orderedStringList.class
插入功能将插入字符串按字母顺序。
尝试将它作为您的orderedStringList.class的参数传递。 – 2013-02-21 02:41:00
你是说你在一个方法中声明一个变量,并试图在另一个方法中访问它?如果是这样,那是不可能的,因为这些范围不相交。 – 2013-02-21 02:42:33