我有一个arraylist< interface>
对象在for循环中被添加到此列表中.每次调用该方法时,我希望这个数组列表为空.
这是代码:
我想在这里清空的数组是SuggestPhrases.
public List returnSuggestedList(String prefix) {
String tempPrefix = prefix;
// suggestedPhrases = null;
//suggestedPhrases = new ArrayList();
//Vector list = new Vector();
//List interfaceList = new ArrayList();
Collections.sort(wordsList);
System.out.println("Sorted Vector contains : " + wordsList);
int i = 0;
//List selected = new ArrayList();
for(String w:wordsList){
System.out.println(w);
if(w.startsWith(prefix.toLowerCase())) { // or .contains(), depending on
//selected.add(w); // what you want exactly
Item itemInt = new Item(w);
suggestedPhrases.add(itemInt);
}
}