这就是我所拥有的。我正在尝试向 indexStruct 类型的 ArrayList 添加一个名称值,但不知道该怎么做。名称是一个字符串,任何帮助都会很棒。谢谢!
import java.util.ArrayList;
public class Currentindex {
public void indexedWords(String currentWord, ArrayList <Indexstruct> currentIndex){
int convoMax=currentIndex.size();
int convoMin=0;
int placeHolder;
int strComp;
//pull words to skip that appear frequently in a typical conversation
while(convoMax>convoMin){ //binary search
placeHolder=(convoMin+convoMax)/2;
strComp=currentWord.compareToIgnoreCase(currentIndex.get(placeHolder).Word);
if(strComp==0){
currentIndex.add(placeHolder, Word); //<--Where problem occurs
break;
}
else if(strComp<0){
convoMax=placeHolder-1;
}
else{
convoMin=placeHolder+1;
}
}
//addterm(currentIndex);
System.out.println(currentIndex);
}
}